Skip to content

Object.seal()

Object.seal() prevents adding or deleting properties but allows modifying existing properties. It’s less restrictive than Object.freeze().

const user = Object.seal({ name: 'Alice', age: 25 });
user.age = 26; // ✅ Allowed — modification
user.email = 'a@b.com'; // ❌ Cannot add
delete user.name; // ❌ Cannot delete
Object.isSealed(user); // true
Featurefreezeseal
Read properties✅✅
Modify properties❌✅
Add properties❌❌
Delete properties❌❌
  • Object.seal() prevents add/delete but allows modification
  • Use when you want to prevent structural changes but allow value updates
  • Check with Object.isSealed()