本文共 658 字,大约阅读时间需要 2 分钟。
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 function.
接受对象作为参数,如果对象是密封的,则返回true
,否则返回false
。 当对象是函数的返回值时,对象将被密封。
Example:
例:
const dog = {}dog.breed = 'Siberian Husky'const myDog = Object.seal(dog)Object.isSealed(dog) //trueObject.isSealed(myDog) //truedog === myDog //true
In the example, both dog
and myDog
are sealed. The argument passed as argument to 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
都是密封的。 作为实传递给实是可变的,不能被取消密封。 它也作为参数返回,因此dog
=== myDog
(它是相同的对象)。
翻译自:
转载地址:http://rmqgb.baihongyu.com/