new function()
does much more than invoking the constructor and returning its output.
It creates a new object. The type of this object is simply object.
It sets this new object's internal, inaccessible, [[prototype]] (i.e.
proto) property to be the constructor function's external, accessible, prototype object (every function object automatically has
a prototype property).
It makes the this variable point to the newly created object.
It executes the constructor function, using the newly created object
whenever this is mentioned.
It returns the newly created object, unless the constructor function
returns a non-null object reference. In this case, that object
reference is returned instead.
However, if the function's constructor already returns a value, then output of new function()
is same as function()
function f1(){ return f1 }
f1() == new f1() //returns true
Without return
statement in constructor
function f1(){ }
f1() == new f1() //returns false