Last active
January 1, 2016 17:09
-
-
Save matthewp/8175510 to your computer and use it in GitHub Desktop.
object.is is a polyfill for the es6 egal function: http://wiki.ecmascript.org/doku.php?id=harmony:egal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = Object.is || function(x, y){ | |
if (x === y) { | |
// 0 === -0, but they are not identical | |
return x !== 0 || 1 / x === 1 / y; | |
} | |
// NaN !== NaN, but they are identical. | |
// NaNs are the only non-reflexive value, i.e., if x !== x, | |
// then x is a NaN. | |
// isNaN is broken: it converts its argument to number, so | |
// isNaN("foo") => true | |
return x !== x && y !== y; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment