🚩attribute
(value/writable) | (get/set) / enumerable / configurable
JS ⟩ value ⟩ object ⟩ property ⟩ attribute
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❗
🔰 redefine property
configurable properties
✅ data property -> accessor property
✅ accessor property -> (non-writable) data property
✅ configurable -> non-configurable ( one-way❗)
✅ enumerable <-> non-enumerable
✅ writable <-> non-writable
✅ value <-> another value
non-configurable properties
✅ writable -> non-writable ( one-way❗)
❌ TypeError (otherwise)
🔰 reassign value (to data property)
✅ writable - can reassign explicitly. (
obj.prop = 1)✅ non-writable , but configurable - can reassign implicitly. (
Object.defineProperty(obj, 'prop', {value: 1}))❌ TypeError (otherwise)
non-writable only means that the value can't be reassigned directly.
if configurable, all the attributes could be changed or overwritten completely (data <-> accessor).
By default, all properties of the objects you create are writable, enumerable, and configurable.
property descriptor - the attributes of an object.
property enumeration - how methods enumerate properties.
obj.mergeWith() - copy properties (and their attributes) from other sources.
Object.assign() copies source's own enumerable properties to target.
replit ⟩ property attributes , require ⟩ Object extension
replit ⟩ Object_ext.js
Last updated