1

In Chrome's JavaScript console:

function placeOrder() {
        return 1;
};
undefined
console.log(placeOrder.prototype);
placeOrder {}

But In IE 11, the default prototype property seems to be an empty object. I wonder what is the object "placeOrder { }" in Chrome? I also tested it in Firefox. In Firefox, the prototype property is "placeOrder { }" too.

In IE 11 console:

function placeOrder() {
        return 1;
};
undefined
console.log(placeOrder.prototype);
undefined
[object Object]{} 

Thanks.

1 Answer 1

3

It's an object which inherits from Object.prototype and has an own constructor property whose value is the constructor function.

See Creating Function Objects

  1. Let proto be the result of creating a new object as would be constructed by the expression new Object() where Object is the standard built-in constructor with that name.
  2. Call the [[DefineOwnProperty]] internal method of proto with arguments "constructor", Property Descriptor {[[Value]]: F, { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true}, and false.
  3. Call the [[DefineOwnProperty]] internal method of F with arguments "prototype", Property Descriptor {[[Value]]: proto, { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}, and false.
Sign up to request clarification or add additional context in comments.

2 Comments

@thermostat That would be a violation of the spec. Probably, it's not an empty object, but IE displays it as an empty object in the console because it has no enumerable property. Use Object.getOwnPropertyNames(placeOrder.prototype) and you will see its own properties.
on ie11 it returns constructor

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.