JavaScript Object.seal() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Object

Definition

Object.seal(obj) seals an object: you cannot add or remove properties, and every property becomes non-configurable.

Writable values can still be updated. For a full lock that also blocks value changes, use Object.freeze. Check with Object.isSealed.

Syntax

Call Object.seal() like this. Start with this line.

JavaScript
Object.seal(obj)
CallWhat it does
Object.seal(obj)Seals obj and returns it.
Object.isSealed(obj)Returns true after sealing.
delete obj.keyFails after seal (ignored in non-strict mode).

Returns the same object. Sealing cannot be undone.

Library declarations
JavaScript
Object.seal(obj)
JavaScript
Object.seal<T>(o: T): T

Parameters

ParameterDescription
objRequired. The object to seal.

Return Value

Return ValueDescription
objectThe same object, now sealed.

JavaScript Examples

Seal and Update a Value

Seal a settings object, change a value, and try to add a key.

JavaScript
var settings = { theme: "dark", lang: "en" };
Object.seal(settings);

settings.theme = "light";
settings.font = "large";
delete settings.lang;

console.log(settings);
console.log(Object.isSealed(settings));
Try It Yourself

How It Works

  1. Value update works. theme changes to "light" because it is still writable.
  2. Add fails. font is not added on a sealed object.
  3. Delete fails. lang stays. Seal blocks removing keys.

Seal Allows Changes; Freeze Does Not

Compare the same assignment on sealed and frozen objects.

JavaScript
var sealed = { n: 1 };
Object.seal(sealed);
sealed.n = 5;
console.log(sealed.n);

var frozen = { n: 1 };
Object.freeze(frozen);
frozen.n = 5;
console.log(frozen.n);
Try It Yourself

How It Works

  1. Sealed write. The sealed object accepts the new value 5.
  2. Frozen write. The frozen object keeps 1 in non-strict mode.
  3. Choose by need. Use seal for fixed keys with live data. Use freeze for read-only data.

Confirm with isSealed and isExtensible

After sealing, both sealed and non-extensible checks should agree.

JavaScript
var profile = { name: "Ada" };
Object.seal(profile);

console.log(Object.isSealed(profile));
console.log(Object.isExtensible(profile));
console.log(Object.isFrozen(profile));
Try It Yourself

How It Works

  1. Sealed. isSealed is true.
  2. Not extensible. Sealing also turns off extensibility.
  3. Not frozen. Values can still change, so isFrozen is false.

Browser & Runtime Support

Object.seal() comes from ES5 and is supported in all modern browsers and Node.js.

✓ ES5 · Baseline

Object.seal()

Available in every current browser and server runtime. Pair with Object.isSealed().

100% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Object.seal Excellent

Bottom line: Safe for production. Use when object shape must stay fixed but property values may still update.

Frequently Asked Questions

It stops adding and removing properties. Existing writable values can still be changed.
No. Use Object.freeze() if values must not change.
No. Sealing is permanent for that object. Copy properties into a new object if you need mutability again.
Yes. Object.isExtensible returns false after seal.
Delete fails. In non-strict mode it is ignored; in strict mode it throws TypeError.

Next: setPrototypeOf()

Change an object’s prototype link.

setPrototypeOf() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful