Wrong behaviour in Google Chrome Object.defineProperty? Wrong behaviour in Google Chrome Object.defineProperty? google-chrome google-chrome

Wrong behaviour in Google Chrome Object.defineProperty?


The Mozilla MDN for Object.defineProperty clarifies this:

Property descriptors present in objects come in two main flavors: data descriptors and accessor descriptors. A data descriptor is a property that has a value, which may or may not be writable. An accessor descriptor is a property described by a getter-setter pair of functions. A descriptor must be one of these two flavors; it cannot be both.

This means, that you can use either one of those:

  • writable and value
  • get and set

But you cannot use any combination of them. In your example, you specify the writable attribute, which means that it is a data descriptor, which disallows get and set attributes.