makeObj[] := Module[{obj, i = 0}, obj["inc"] := ++i; obj["dec"] := --i; obj[] := i; obj]; makeObj = function() { var i = 0; var obj = function(in) { switch(in) { case "inc" : return ++i; case "dec" : return --i; case undefined: return i; }; }; return obj; };