JS: Object.prototype.propertyIsEnumerable ❌
obj.propertyIsEnumerable(key)-
Return
trueif key is a own key and Enumerable. Else,false.console.log({ "p": 4 }.propertyIsEnumerable("p")); 🛑 WARNING:
Object.prototype.propertyIsEnumerablewon't work if a object has a property of that name. Better is to use Reflect.getOwnPropertyDescriptor.// demo, problem of propertyIsEnumerable when a object has that property name. const jj = { "pp": 4, "propertyIsEnumerable": ((x) => x + " haha") }; console.assert(jj.propertyIsEnumerable("pp") === "pp haha");
JavaScript. Define Properties and attributes.
- JS: Property Attributes
- JS: Enumerable Property
- JS: Property Descriptor
- JS: Object.create
- JS: Object.defineProperty ❌
- JS: Reflect.defineProperty
- JS: Object.defineProperties
- JS: Object.prototype.propertyIsEnumerable ❌
- JS: Object.getOwnPropertyDescriptor ❌
- JS: Reflect.getOwnPropertyDescriptor
- JS: Object.getOwnPropertyDescriptors