JS Built-ins
ObjectObject.isExtensiblebeginner

Object.isExtensible() β€” after preventExtensions

πŸ“– 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() after preventExtensions

Once Object.preventExtensions(obj) is called, the object cannot have new properties added.

Challenge: Write a function that calls Object.preventExtensions and returns whether the result is extensible.

πŸ’‘ Hints (1)
  • β€’ All of freeze, seal, and preventExtensions make an object non-extensible