关键字:seal, freeze, property descriptor. 1.Object.seal() 参考文档(2)中这样描述: The Object.seal() method seals an object, preventing new properties from being added to it and marking all existing properties as non-configurable. Values of present properties can…
let person = { firstName: "Zhentian", lastName: "Wan" }; /*Object.freeze() makes object cannot be updated, added or deleted*/ let freezePerson = Object.freeze(person); freezePerson.address="Finland"; // Cannot add property ad…
1 Object.seal(O)的调用 When the seal function is called, the following steps are taken: If Type(O) is not Object throw a TypeError exception. For each named own property name P of O, Let desc be the result of calling the [[GetOwnProperty]] int…
Object对象详细参考 本文参考MDN做的详细整理,方便大家参考MDN JavaScript原生提供一个Object对象(注意起首的O是大写),所有其他对象都继承自这个对象. 构造函数: Object 构造函数为给定的值创建一个对象包装. 如果给定值是 null or undefined,将会创建并返回一个空对象 否则,将返回一个与给定值对应类型的对象. 当以非构造函数形式被调用时,Object() 等同于 new Object(). var o1 = new Object();//创建空对象…