Skip to content

Instantly share code, notes, and snippets.

@maciejtrzcinski
Created October 30, 2018 19:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maciejtrzcinski/1fc7971b8db29287f84a82f311c3bb9f to your computer and use it in GitHub Desktop.
Save maciejtrzcinski/1fc7971b8db29287f84a82f311c3bb9f to your computer and use it in GitHub Desktop.
if (!Object.is) {
Object.is = function(x, y) {
// SameValue algorithm
if (x === y) { // Steps 1-5, 7-10
// Steps 6.b-6.e: +0 != -0
return x !== 0 || 1 / x === 1 / y;
} else {
// Step 6.a: NaN == NaN
return x !== x && y !== y;
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment