console.log(
'Object.is(NaN, NaN)', Object.is(NaN, NaN), // true
'Object.is(-0, +0)', Object.is(-0, +0), // false
);
console.log(
'NaN === NaN', NaN === NaN, // false
'+0 === -0', +0 === -0 // true
);
const AObj = {
name: 'A'
}
let BObj = AObj;
console.log( 'NaN, +0, -0',
Object.is(NaN, NaN), // true
Object.is(-0, +0), // false
);
console.log( 'Object.is',
Object.is(AObj, BObj), // true
);
BObj.name = 'B'; // ---> 即便值改了仍與A同參考, 一起改
console.log( 'Object.is(AObj, BObj)',
Object.is(AObj, BObj), // true
);
const CObj = {
name: 'A'
};
console.log( 'Object.is(AObj, CObj)',
Object.is(AObj, CObj), // false
);
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.