Hi guys,
how do you make a singleton access class?
Do you know a better way of this one:
var singletonClass = (function( )
{
// Private variable
var instance = null;
// Private Constructor
function myClass( )
{
//...
}
return new function( )
{
this.constructo r = null;
this.getInstanc e = function( )
{
if( ! instance )
{
instance = new myClass( );
instance.constr uctor = null;
}
return instance;
}
}
})( );
how do you make a singleton access class?
Do you know a better way of this one:
var singletonClass = (function( )
{
// Private variable
var instance = null;
// Private Constructor
function myClass( )
{
//...
}
return new function( )
{
this.constructo r = null;
this.getInstanc e = function( )
{
if( ! instance )
{
instance = new myClass( );
instance.constr uctor = null;
}
return instance;
}
}
})( );
Comment