is.js 581 B

1234567891011121314151617181920212223
  1. /**
  2. * Check if both arguments are egal.
  3. */
  4. function is(x, y){
  5. // implementation borrowed from harmony:egal spec
  6. if (x === y) {
  7. // 0 === -0, but they are not identical
  8. return x !== 0 || 1 / x === 1 / y;
  9. }
  10. // NaN !== NaN, but they are identical.
  11. // NaNs are the only non-reflexive value, i.e., if x !== x,
  12. // then x is a NaN.
  13. // isNaN is broken: it converts its argument to number, so
  14. // isNaN("foo") => true
  15. return x !== x && y !== y;
  16. }
  17. module.exports = is;