soutsjjw
8/16/2019 - 1:09 PM

ES5 實現 Object.is

ES5 實現 Object.is

Object.defineProperty(Object, 'is', {
    value: function(x, y) {
        if (x === y) {
            return x !== 0 || 1 / x === 1 / y;
        }
        return x !== x && y !== y;
    },
    configurable: true,
    enumerable: false,
    writable: true
});