RSS
 

Archive for May, 2009

JavaScript: Private Static Members, Part 2

19 May

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.

  1. var myFunc = (function () {
  2.   return function () {
  3.     alert("Hello, World!");
  4.   }
  5. })();
  6.  
  7. alert(myFunc); // "function () … "
  8.  
  9. myFunc(); // Hello, World!

Read the rest of this entry »

 
Comments Off

Posted in Articles