Thursday, November 6, 2008

Function as variable

In Javascript, function is first-class object, which is mean that a function is regarded as a data type which the value can be saved in local vaiables, passed as paramenters and assigned.

Keep in mind the javasript objects is understanding as collection (key value)pairs.

JavaScript doesn't support the notion of private memebers as C#, but we can simulate the functionality by ising variables inside the function. by declared the variable using keyword "var" instead of "this", thus acting like private members. Variables can, however, be accessed by closure functions.

No comments: