Static Classes in Javascript

With the rise of AJAX and Google Api’s javascript is hot again, with the new scriptmanager of ASP.NET it is very easy to integrate javascript with server side code.
 
Today I encountered a Static Function in javascript, my collegues and i were unsure how to use this. It is pretty easy once you know it. The code is as below:
 
/**
 * Static class for handling test creation.
 * @class
 */                    
function testClass()
{
}
 
/*Static function*/
testClass.getInfo= function (){
  return 1;
}
 
You can call it in code:
var value = testClass.getInfo();
 
 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.