JS: Object Literal Expression vs Object.Create
Object Literal Expression vs Object.Create
{key:val}
is equivalent to
Object.create(
Object.prototype,
{key:
{value:val,
enumerable: true,
configurable: true,
writable: true}})
// check equivalence of object literal and Object.create const xx = { "kk": 1 }; const yy = Object.create( Object.prototype, { "kk": { value: 1, enumerable: true, configurable: true, writable: true } }, ); console.assert(Reflect.getPrototypeOf(xx) === Reflect.getPrototypeOf(yy)); console.assert((Object.isExtensible(xx)) === true); console.assert((Object.isExtensible(yy)) === true); console.assert( JSON.stringify(Reflect.getOwnPropertyDescriptor(xx, "kk")) === JSON.stringify(Reflect.getOwnPropertyDescriptor(yy, "kk")), ); // Object.entries(Reflect.getOwnPropertyDescriptor(xx, "kk")) // [ [ "value", 1 ], [ "writable", true ], [ "enumerable", true ], [ "configurable", true ] ]
JavaScript. Object and Inheritance
- JS: Object (basics)
- JS: Object Overview
- JS: Object Type
- JS: Test is Object Type 📜
- JS: Determine Type of Object
- JS: Prototype and Inheritance
- JS: Prototype Chain
- JS: Object.prototype.isPrototypeOf
- JS: Get Set Prototype
- JS: Show Prototype Chain 📜
- JS: Prototype Tree
- JS: Dot Notation and Prototype Chain
- JS: Create Object
- JS: Object Literal Expression
- JS: Object.create
- JS: Object Literal Expression vs Object.Create
- JS: Create Object with Parent X
- JS: Prevent Adding Property
- JS: Deep Copy Array or Object 📜
- JS: Test Equality of Array and Object by Content 📜
- JS: Add Method to Prototype
- JS: Object (class)
- JS: Object Constructor
- JS: Object.prototype