I tried to simulate the \'new\' operator in JavaScript in a code like this:
Function.method(\'new\', function ( ) {
var objPrototype = Object.create(this
Here is an alternative to using the __proto__ approach. Its in line with how the OP initially started out...
function New(fn) {
var newObj = Object.create(fn.prototype);
return function() {
fn.apply(newObj, arguments);
return newObj;
};
}
This is a much cleaner way of doing it, and it passes prototype chain tests too.