Detaching <Object> .prototype.constructor

In JavaScript, when I define a new function

function Foo () { /* code */ }

      

The prototype of this function is assigned to a new object, and the object is constructor

set to the newly created function, so

Foo.prototype.constructor === Foo

      

This behavior is well documented in both the ECMAScript specification and the more user-friendly MDN .

Is this property used in any other way than just a friendly shortcut to access the constructor function?

For example, if I were

delete Object.prototype.constructor

      

(which I can, since at least in Node.js the property is defined to be writable and configurable ), I somehow affect the functionality of the language

After some rudimentary tests, this does not affect the definition of creating new objects as the property is defined correctly for every new function / object that I create.

Note. I know this might break third party code - I'm only interested in the functionality of the main language.

+3


source to share





All Articles