| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/seal | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 7.
Object.seal() . , . ( : Object.freeze() ).
const object1 = {
property1: 42,
};
Object.seal(object1);
object1.property1 = 33;
console.log(object1.property1);
// Expected output: 33
delete object1.property1; // Cannot delete when sealed
console.log(object1.property1);
// Expected output: 33
Object.seal(obj);
obj.
.
(extensible). , . , (non-configurable) . . (data properties) (accessor properties), . Object.freeze() , Object.seal() . , / , strict mode TypeError .
. Object.prototype.__proto__ .
var obj = {
prop: function () {},
foo: "bar",
};
// ,
obj.foo = "baz";
obj.lumpy = "woof";
delete obj.prop;
var o = Object.seal(obj);
assert(o === obj);
assert(Object.isSealed(obj) === true);
//
obj.foo = "quux";
obj.foo; // 'quux'
//
Object.defineProperty(obj, "foo", {
get: function () {
return "g";
},
}); // TypeError
//
obj.quaxxor = "the friendly duck"; //
delete obj.foo; //
// strict mode TypeError
function fail() {
"use strict";
delete obj.foo; // TypeError
obj.sparky = "arf"; // TypeEror
}
fail();
// Object.defineProperty() TypeError
Object.defineProperty(obj, "ohai", { value: 17 }); // TypeErorr
Object.defineProperty(obj, "foo", { value: "eit" }); //
ES5 Object.seal() (, ) TypeError . ES6 TypeError .
> Object.seal(1)
TypeError: 1 is not an object // ES5 code
> Object.seal(1)
1 // ES6 code
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-object.seal |
Object.isSealed()Object.preventExtensions()Object.isExtensible()Object.freeze()Object.isFrozen()This page was last modified on 2026 7 15 by MDN contributors.
ObjectObject.assign()Object.create()Object.defineProperties()Object.defineProperty()Object.entries()Object.freeze()Object.fromEntries()Object.getOwnPropertyDescriptor()Object.getOwnPropertyDescriptors()Object.getOwnPropertyNames()Object.getOwnPropertySymbols()Object.getPrototypeOf()Object.groupBy()Object.hasOwn()Object.is()Object.isExtensible()Object.isFrozen()Object.isSealed()Object.keys()Object.preventExtensions()Object.seal()setPrototypeOf()Object.values()Object.prototype.__defineGetter__()Object.prototype.__defineSetter__()Object.prototype.__lookupGetter__()Object.prototype.__lookupSetter__()Object.prototype.hasOwnProperty()Object.prototype.isPrototypeOf()Object.prototype.propertyIsEnumerable()Object.prototype.toLocaleString()Object.prototype.toString()Object.prototype.valueOf()Object/FunctionObject.prototype.__defineGetter__()Object.prototype.__defineSetter__()Object.prototype.__lookupGetter__()Object.prototype.__lookupSetter__()Object.prototype.hasOwnProperty()Object.prototype.isPrototypeOf()Object.prototype.propertyIsEnumerable()Object.prototype.toLocaleString()Object.prototype.toString()Object.prototype.valueOf()Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |