I don't understand writable and configurable property attributes of Objects

后端 未结 4 949
我在风中等你
我在风中等你 2021-01-19 11:10

I don\'t understand the Writable and Configurable attributes of Objects. For example, in the MDN for Object.prototype, there is a table where I can clearly see that Configur

4条回答
  •  南方客
    南方客 (楼主)
    2021-01-19 11:27

    The Writable, Enumerable and Configurable attributes in MDN appear to be about the Object.prototype object itself, not its properties.

    So, what that means is that you can't replace Object.prototype with a different object, but you are allowed to add properties to it.

    So, what that means is if you do this:

    Object.prototype = {foo: "whatever"};   // doesn't work - is just ignored
    var j = {};
    console.log(j.foo);   // undefined
    

    Then, the first line of code won't do anything.

提交回复
热议问题