EDIT: init() returns this , thanks Guffa.
You define an anonymous function, but don't really name it. To call it right away, add a pair of parentheses:
var obj = (function(){ return{ init: function(){ console.log("initialized!"); return this; }, uninit: function(x){ console.log("uninitialized!"); } }; })().init();
source share