After my last question, this is more accurate for me:
Example:
function Foo() {
this.bla = 1;
var blabla = 10;
blablabla = 100;
this.getblabla = function () {
return blabla;
}
}
foo = new Foo();
what i understand now:
this.bla = 1; // will become an attribute of every instance of FOO.
var blabla = 10; // will become a local variable of Foo(will **not** become an attribute of every instance of FOO), which could be accessed by any instance of FOO - only if there a method like "this.getBlabla". that a "closer" ?
blablabla = 100; // will define a **new** (or change if exist) global(window) variable.
Do I understand correctly?
Also - if I include the var blabla = 10;function getblablathat uses it in the contractor, then for each instance of Foo ("foo" ...), the function of the Foo contractor will be stored in memory, which includes this variable "private". or will it be the same Foo function as the place for private variables - for ALL instances (like "foo") of Foo?
source
share