导航
var obj = {a: 2};
Object.preventExtensions(obj)
obj.b = 3;
console.log(obj);
var obj = {a: 2};
var obj2 = {a: 2};
Object.preventExtensions(obj)
console.log(Object.isExtensible(obj));
console.log(Object.isExtensible(obj2));
var obj = {a: 2};
obj.c = 8;
Object.defineProperty(obj, 'b', {
value: 6
})
console.log(Object.getOwnPropertyDescriptor(obj, 'b'));
console.log(Object.getOwnPropertyDescriptor(obj, 'c'));
var obj = {a: 2};
Object.seal(obj);
obj.b = 3;
console.log(Object.isSealed(obj));
console.log(obj);
var obj = {a: 2};
Object.freeze(obj);
console.log(Object.isFrozen(obj));
function myFreeze(obj) {
Object.freeze(obj);
for (var key in obj) {
if (typeof(obj[key]) === 'object' && obj[key] !== null) {
myFreeze(obj[key]);
}
}
}
var obj = {
a: {
b: {
c: 123
}
}
}
myFreeze(obj);
obj.a.b.d = 345;
console.log(obj);
console.log(NaN === NaN);
console.log(+0 === -0);
console.log(Object.is(NaN, NaN));
console.log(Object.is(+0, -0));