Why does the engine report that the function Empty()
is the prototype of the native Function
function in JavaScript, but that function is itself undefined (from the user's point of view)?
Function.prototype; // function Empty()
Function.__proto__; // function Empty()
Function.constructor; // function Function()
Empty(); // Uncaught ReferenceError: Empty is not defined
Object.prototype; // Object {}
Object.__proto__; // function Empty()
Object.constructor; // function Function()
Number.prototype; // Number {[[PrimitiveValue]]: 0}
Number.__proto__; // function Empty()
Number.constructor; // function Function()
String.prototype; // String {length: 0, [[PrimitiveValue]]: ""}
String.__proto__; // function Empty()
String.constructor; // function Function()
Boolean.prototype; // {[[PrimitiveValue]]: false}
Boolean.__proto__; // function Empty()
Boolean.constructor; // function Function()
Why not point all of those references to Empty()
to null
or some empty object?
Because the
Function.prototype
object is basically an empty function.I don't see what you mean,
Function.prototype
is pretty defined. If you mean the identifierEmpty
, there's no reason it would be a global variable just because it's used for the name of a function.Because that would destroy inheritance.
It is an empty object - an empty function object. Why not a plain object? Because the spec says so.