JS Built-ins
← Object135 / 150
ObjectpropertyIsEnumerableadvanced

propertyIsEnumerable() β€” after defineProperty with enumerable:false

πŸ“– Usage Example
// Check if a property shows up in for...in loops
const obj = { a: 1 }
obj.propertyIsEnumerable('a')   // β†’ true
Object.defineProperty(obj, 'b', { value: 2, enumerable: false })
obj.propertyIsEnumerable('b')   // β†’ false

Use propertyIsEnumerable() to check whether a specific own property will appear during enumeration (e.g., for...in or Object.keys).

propertyIsEnumerable() β€” changing enumerability

You can change enumerability of an existing property with Object.defineProperty.

Challenge: Change a property from enumerable to non-enumerable and verify with propertyIsEnumerable().

πŸ’‘ Hints (1)
  • β€’ Enumerability can be toggled with defineProperty on configurable properties