Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var A = function(x,y){var a=arguments,b=a[0],c=a.callee,d=this;if(!(d instanceof c))return new c(a);if(c==b.callee)return c.apply(d,b);d.x=x;d.y=y;};
- var a = A(1,2);
- console.log(a.x, a.y); // 1 2
- console.log(a instanceof A); // true
- var b = new A(3,4);
- console.log(b.x,b.y); // 3 4
- console.log(b instanceof A); // true
Advertisement
Add Comment
Please, Sign In to add comment