Here is what I\'d like to do:
function a() { // ... } function b() { // Some magic, return a new object. } var c = b(); c instanceof b // -> true c
Yes you can do this.
var User = function() { var privateMethod = function() { alert('hello'); } return { sayHello : function() { privateMethod(); this.done = true; } } } var user1 = User();
Is anything wrong with this method?