Object

Object.seal

Seals an object, preventing new properties from being added and marking all existing properties as non-configurable

Syntax

JavaScript
Object.seal(obj)

Parameters

ParameterTypeDescription
objTThe object to seal

Return Value

The same object that was passed in

Examples

Basic Usage
const obj = { name: 'Alice', age: 30 };
Object.seal(obj);
obj.age = 31; // works
obj.email = '[email protected]'; // fails silently
console.log(obj); // { name: 'Alice', age: 31 }
Practical Example
const config = Object.seal({ debug: false });
config.debug = true; // allowed
delete config.debug; // fails
console.log(config); // { debug: true }
Advanced Usage
const sealed = Object.seal([1, 2, 3]);
sealed[0] = 10; // works
// sealed.push(4); // TypeError
console.log(sealed); // [10, 2, 3]

Understanding Object.seal

The Object.seal method in JavaScript seals an object, preventing new properties from being added and marking all existing properties as non-configurable. It belongs to the Object object and is one of the most widely used methods for working with object values in modern JavaScript and TypeScript applications.

The method signature is Object.seal(obj). It accepts 1 parameter: obj. When called, it returns the same object that was passed in. Understanding when and how to use seal() helps you write more expressive, readable code.

Common use cases for Object.seal include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like object-issealed, object-freeze, object-isfrozen, enabling you to chain operations together for complex data manipulation pipelines.

Browser support for Object.seal is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.

Browser Compatibility

Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.

Related Methods

More Object Methods

Other methods in the Object object

Related Tools

More Object Methods

Explore JavaScript Methods

Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.