Object.seal() - JavaScript | MDN Skip to main content Skip to search MDN HTML HTML: Markup language HTML reference Elements Global attributes Attributes See all… HTML guides Responsive images HTML cheatsheet Date & time formats See all… Markup languages SVG MathML XML CSS CSS: Styling language CSS reference Properties Selectors At-rules Values See all… CSS guides Box model Animations Flexbox Colors See all… Layout cookbook Column layouts Centering an element Card component See all… JavaScriptJS JavaScript: Scripting language JS reference Standard built-in objects Expressions & operators Statements & declarations Functions See all… JS guides Control flow & error handing Loops and iteration Working with objects Using classes See all… Web APIs Web APIs: Programming interfaces Web API reference File system API Fetch API Geolocation API HTML DOM API Push API Service worker API See all… Web API guides Using the Web animation API Using the Fetch API Working with the History API Using the Web speech API Using web workers All All web technology Technologies Accessibility HTTP URI Web extensions WebAssembly WebDriver See all… Topics Media Performance Privacy Security Progressive web apps Learn Learn web development Frontend developer course Getting started modules Core modules MDN Curriculum Check out the video course from Scrimba, our partner Learn HTML Structuring content with HTML module Learn CSS CSS styling basics module CSS layout module Learn JavaScript Dynamic scripting with JavaScript module Tools Discover our tools Playground HTTP Observatory Border-image generator Border-radius generator Box-shadow generator Color format converter Color mixer Shape generator About Get to know MDN better About MDN Advertise with us Community MDN on GitHub Blog Toggle sidebar Web JavaScript Reference Standard built-in objects Object seal() Theme OS default Light Dark English (US) Remember language Learn more Deutsch English (US) Español Français 日本語 한국어 Português (do Brasil) Русский 中文 (简体) Object.seal() Baseline Widely available This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015. Learn more See full compatibility The Object.seal() static method seals an object. Sealing an object prevents extensions and makes existing properties non-configurable. A sealed object has a fixed set of properties: new properties cannot be added, existing properties cannot be removed, their enumerability and configurability cannot be changed, and its prototype cannot be re-assigned. Values of existing properties can still be changed as long as they are writable. seal() returns the same object that was passed in. In this article Try it Syntax Description Examples Specifications Browser compatibility See also Try it const object = { foo: 42, }; Object.seal(object); object.foo = 33; console.log(object.foo); // Expected output: 33 delete object.foo; // Cannot delete when sealed console.log(object.foo); // Expected output: 33 Syntax js Object.seal(obj) Parameters obj The object which should be sealed. Return value The object being sealed. Description Sealing an object is equivalent to preventing extensions and then changing all existing properties' descriptors to configurable: false. This has the effect of making the set of properties on the object fixed. Making all properties non-configurable also prevents them from being converted from data properties to accessor properties and vice versa, but it does not prevent the values of data properties from being changed. Attempting to delete or add properties to a sealed object, or to convert a data property to accessor or vice versa, will fail, either silently or by throwing a TypeError (most commonly, although not exclusively, when in strict mode code). Private elements are not properties and do not have the concept of property descriptors. Private elements cannot be added or removed from the object, whether the object is sealed or not. The prototype chain remains untouched. However, due to the effect of preventing extensions, the [[Prototype]] cannot be reassigned. Unlike Object.freeze(), objects sealed with Object.seal() may have their existing properties changed, as long as they are writable. Examples Using Object.seal js const obj = { prop() {}, foo: "bar", }; // New properties may be added, existing properties // may be changed or removed. obj.foo = "baz"; obj.lumpy = "woof"; delete obj.prop; const o = Object.seal(obj); o === obj; // true Object.isSealed(obj); // true // Changing property values on a sealed object // still works. obj.foo = "quux"; // But you can't convert data properties to accessors, // or vice versa. Object.defineProperty(obj, "foo", { get() { return "g"; }, }); // throws a TypeError // Now any changes, other than to property values, // will fail. obj.quaxxor = "the friendly duck"; // silently doesn't add the property delete obj.foo; // silently doesn't delete the property // … and in strict mode such attempts // will throw TypeErrors. function fail() { "use strict"; delete obj.foo; // throws a TypeError obj.sparky = "arf"; // throws a TypeError } fail(); // Attempted additions through // Object.defineProperty will also throw. Object.defineProperty(obj, "ohai", { value: 17, }); // throws a TypeError Object.defineProperty(obj, "foo", { value: "eit", }); // changes existing property value Non-object argument In ES5, if the argument to this method is not an object (a primitive), then it will cause a TypeError. In ES2015, a non-object argument will be returned as-is without any errors, since primitives are already, by definition, immutable. js Object.seal(1); // TypeError: 1 is not an object (ES5 code) Object.seal(1); // 1 (ES2015 code) Specifications Specification ECMAScript® 2027 Language Specification # sec-object.seal Browser compatibility Enable JavaScript to view this browser compatibility table. See also Object.isSealed() Object.preventExtensions() Object.isExtensible() Object.freeze() Object.isFrozen() Help improve MDN Was this page helpful to you? Yes No Learn how to contribute This page was last modified on Jul 20, 2025 by MDN contributors. View this page on GitHub • Report a problem with this content Filter sidebar Clear filter input Standard built-in objects Object Constructor Object() Static methods assign() create() defineProperties() defineProperty() entries() freeze() fromEntries() getOwnPropertyDescriptor() getOwnPropertyDescriptors() getOwnPropertyNames() getOwnPropertySymbols() getPrototypeOf() groupBy() hasOwn() is() isExtensible() isFrozen() isSealed() keys() preventExtensions() seal() setPrototypeOf() values() Instance methods __defineGetter__() __defineSetter__() __lookupGetter__() __lookupSetter__() hasOwnProperty() isPrototypeOf() propertyIsEnumerable() toLocaleString() toString() valueOf() Instance properties __proto__ constructor Inheritance Object/Function Static methods apply() bind() call() toString() [Symbol.hasInstance]() Static properties displayName length name prototype arguments caller Instance methods __defineGetter__() __defineSetter__() __lookupGetter__() __lookupSetter__() hasOwnProperty() isPrototypeOf() propertyIsEnumerable() toLocaleString() toString() valueOf() Instance properties __proto__ constructor MDN Your blueprint for a better internet. MDN About Blog Mozilla careers Advertise with us MDN Plus Product help Contribute MDN Community Community resources Writing guidelines MDN Discord MDN on GitHub Developers Web technologies Learn web development Guides Tutorials Glossary Hacks blog Mozilla Website Privacy Notice Telemetry Settings Legal Community Participation Guidelines Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.