Creating Objects: User-defined objects can be defined in two ways:
When to use var
Consider the following 2 statements:
var foo = "hi";
bar = "hi";
Both the above statements create a variable, if they are executed at the global level.
But if the context is not global, i.e. we are inside some function, then the
Private members in an object
Only exception are the variables declared using ‘var’ in the constructor. These variables are visible only in the constructor, not visible even to other public members of the class.
So truly speaking, these variables/methods are not even private, they are like local variables of the constructor.
|Email:||(Your email is not shared with anybody)|