🚩attribute

(value/writable) | (get/set) / enumerable / configurable

JSvalueobjectproperty ⟩ attribute

each property has a name and 4 attributes

  • data property - value / writable / enumerable / configurable

  • accessor property - get / set / enumerable / configurable

    • can be a getter, setter (only), or getter/setter.

where:

  • writable - value (of a data property) can be reassigned.

  • enumerable - property is enumerated by for-in loop.

  • configurable - property can be deleted / attributes can be changed (👉 ⭐️ 重點)

🈯 synonyms: "property flag"

Object.assign()

  • only copies the values of enumerable properties, not their attributes

  • if one of the source objects has an accessor property, it is the value returned by the getter that is copied to the target object, not the getter itself

Last updated