My question is regarding the resulting object from using new function(){ ... } over new Function();
My understanding so far/assumption
- When we create a function using Function() or new Function() we get a object configured as a function (it's internal slots indicate a function type object)
- With or without the new operator, the Function() constructor returns a new function object
- Using a function expression returns a function object which internally uses the Function() constructor
- A function expression provides optimization with parsing the function body
My question
Following my assumption above, why does new Function(); and new function(){ ... } return different things?
The first returns a function object, but the latter returns a standard object. Given that a function expression under the hood uses the Function() constructor, why does the latter not behave the same as new Function();?
Using new function(){ ...} I would expect a function object, not a standard object.
function(){} == new Function(),new function () {} == new new Function().