JS Built-ins
← Object110 / 150
ObjectObject.sealbeginner

Object.seal() β€” returns the same object

πŸ“– 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() β€” in-place mutation

Object.seal() modifies and returns the same object β€” it does not create a copy.

Challenge: Verify that Object.seal() returns the same object reference.

πŸ’‘ Hints (1)
  • β€’ Object.seal, freeze, and preventExtensions all return the modified object