java script singleton class

0 votes
34 views
asked Nov 29, 2012 in java script by jonathan (3,105 points)
hi friends.

   is there any way to create sigleton class in javascript?

1 Answer

0 votes
answered Nov 29, 2012 by anonymous

 

 

 

I think the easiest way is to declare a simple object literal:

function InEvents()

{

    this.ChangeListener=null;      

    this.setChangeListener=function(listener)    {

       //do something

    }  

}

var Events=new InEvents();

 

for more information just refer the below link

http://stackoverflow.com/questions/1635800/javascript-best-singleton-pattern?lq=1

...