Since it is not possible to use new operator with an arguments array (.call or .apply), Then I wondering if I can do it by hand.
In the following code, are obj1 and obj2 equivalent (in ES3) ?
function MyClass(a, b, c) {}
var obj1 = new MyClass(2,3,4)
var tmp = function() {}
tmp.prototype = MyClass.prototype;
var obj2 = new tmp;
obj2.constructor = MyClass;
MyClass.call(obj2, 2,3,4);
- edit1 -
Does your answers mean that the above code is wrong or is not equivalent to an object construction ?