JS Built-ins
ObjectObject.isExtensibleintermediate

Object.isExtensible() β€” combining checks

πŸ“– Usage Example
// Check if new properties can be added
const obj = { a: 1 }
Object.isExtensible(obj)             // β†’ true
Object.preventExtensions(obj)
Object.isExtensible(obj)             // β†’ false

Use Object.isExtensible() to check whether new properties can still be added to an object.

Object.isExtensible() β€” combining checks

Use Object.isExtensible() to guard against inadvertently modifying locked objects.

Challenge: Implement safeAddProperty(obj, key, value) that only adds the property if the object is extensible, and returns whether the property was added.

πŸ’‘ Hints (1)
  • β€’ Check isExtensible before adding properties to avoid silent failures