JS Built-ins
← Object106 / 150
ObjectObject.sealbeginner

Object.seal() β€” basics

πŸ“– Usage Example
// Prevent adding/removing properties but allow value changes
const obj = Object.seal({ x: 1 })
obj.x = 99     // allowed β€” value can change
delete obj.x   // silently ignored
obj.x          // β†’ 99

Use Object.seal() to prevent adding or deleting properties on an object while still allowing existing values to be updated.

Object.seal()

Object.seal(obj) prevents new properties from being added AND makes all existing properties non-configurable. Writable properties can still have their values changed.

Challenge: Implement sealObject(obj) that seals the object and returns it.

πŸ’‘ Hints (1)
  • β€’ seal prevents structural changes but allows value changes