Finally, it’s time to finish up the lesson on private static members and methods in JavaScript.
Last time, I introduced the technique of creating and immediately executing a function, using parentheses. I talked a little about returning a function and storing it in a variable.
-
var myFunc = (function () {
-
return function () {
-
alert("Hello, World!");
-
}
-
})();
-
-
alert(myFunc); // "function () … "
-
-
myFunc(); // Hello, World!