Q:

"new" operator in JavaScript

I'm trying to understand the new operator. Have a look at the following function:
var _new = function(fn) {
    var obj = Object.create(fn.prototype);
    fn.apply(obj);
    obj.constructor = fn; // <--- EDIT: unnecessary
    return obj;
};

which can be applied like that:
var Test = function(){
    this.foo = 1;
};

var instance = _new(Test);

Of course it can be easily extended to arbitrary number of arguments (I'm just trying to keep it simple).
It seems that it works like new keyword. So what is the difference if any? What else new operator does to an object?

A:

You are right, this is basically what new is doing: Create a new object that inherits from Func.prototype and call Func with this referring to this new object.
There is a slight difference to your implementation though: If the constructor (Func) does not return an object, this is implicitly returned. If it returns an object (any object) than it will become the return value of the constructor call.
So a more accurate replication would be:
var _new = function(fn) {
    var obj = Object.create(fn.prototype);
    var result = fn.apply(obj);
    return result != null && typeof result === 'object' ? result : obj;
};

That's it. You can see it as syntactic sugar if you want to, just like the conditional operator.

Some pointers to the reference: When new is used, the internal [[Construct]] function of the constructor is called. What exactly happens is described in section 13.2.2 of the specification and it pretty much does the same as the function you (and I) wrote.
The point I'm not completely sure about is that the object's internal [[Extensible]] property is set to true. I would assume that every object you create via Object.create is extensible by default (if it's prototype is extensible).

