JS Built-ins
← Object108 / 150
ObjectObject.sealintermediate

Object.seal() β€” writable properties remain writable

πŸ“– 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() β€” values can still change

Unlike Object.freeze(), sealing does NOT make properties non-writable. You can still change values of existing properties.

Challenge: Show that a sealed object's properties can still be updated.

πŸ’‘ Hints (1)
  • β€’ seal = non-extensible + non-configurable, but writable values still change