Accepts an object as argument, and returns true
if the object is sealed, false
otherwise. Objects are sealed when they are return values of the Object.seal()
function.
接受对象作为参数,如果对象是密封的,则返回true
,否则返回false
。 当对象是Object.seal()
函数的返回值时,对象将被密封。
Example:
例:
const dog = {}
dog.breed = 'Siberian Husky'
const myDog = Object.seal(dog)
Object.isSealed(dog) //true
Object.isSealed(myDog) //true
dog === myDog //true
In the example, both dog
and myDog
are sealed. The argument passed as argument to Object.seal()
is mutated, and can’t be un-sealed. It’s also returned as argument, hence dog
=== myDog
(it’s the same exact object).
在此示例中, dog
和myDog
都是密封的。 作为实Object.seal()
传递给Object.seal()
实Object.seal()
是可变的,不能被取消密封。 它也作为参数返回,因此dog
=== myDog
(它是相同的对象)。