Open weijiyang opened 4 years ago
举例说明 +0 === 0 === -0 但是 1/+0 === +Infinity 1/-0 === -Infinity NaN !==NaN 的问题
下面是 Object.is 的源码实现
Object.prototype.is = function(x, y){ if(x === y){ return x !== 0 || y!==0 || 1/x === 1/y // 让 +0 != -0 } else { return x !== x && y !== x // 让 NaN == NaN } }
举例说明 +0 === 0 === -0 但是 1/+0 === +Infinity 1/-0 === -Infinity NaN !==NaN 的问题
下面是 Object.is 的源码实现