I'd like to initialize an object in javascript calling directly a method that belongs to it:
var obj = (function(){
return{
init: function(){
console.log("initialized!");
return this;
},
uninit: function(x){
console.log("uninitialized!");
}
};
}).init();
//later
obj.uninit();
obj.init();
This specific example doesn't work, is there something similar?