Skip to content

Commit

Permalink
feat(Object): add Object.is() (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
bigopon authored and EisenbergEffect committed Jan 24, 2018
1 parent a01ace2 commit 3cf3410
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,21 @@ if (typeof FEATURE_NO_ES2015 === 'undefined') {
});
}(Object));

/**
* Object.is() polyfill
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
*/
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;
}
};
}

} // endif FEATURE_NO_ES2015

0 comments on commit 3cf3410

Please sign in to comment.