Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to declare private object in java script. I have decided all private variable is of type local. So I have created following method.
I have following 2 option of doing declaration.

JavaScript
var helper=helper||{};

function(publicMethod){
var privateMthod={}; //Option1
var privateMethod=this; //Option2

privateMethod.complexTask=function(){
//some code...
}

publicMethod.f1=function(){
   privateMethod.complexTask();
}
}(helper)


Which option is correct Option1 and Option2?
What is deference between Option1 and Option2?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900