identical.js 567 B

12345678910111213141516171819202122232425
  1. "use strict";
  2. var isNaN = require("./is-nan");
  3. var isNegZero = require("./is-neg-zero");
  4. /**
  5. * @name samsam.equal
  6. * @param Object obj1
  7. * @param Object obj2
  8. *
  9. * Returns ``true`` if two objects are strictly equal. Compared to
  10. * ``===`` there are two exceptions:
  11. *
  12. * - NaN is considered equal to NaN
  13. * - -0 and +0 are not considered equal
  14. */
  15. function identical(obj1, obj2) {
  16. if (obj1 === obj2 || (isNaN(obj1) && isNaN(obj2))) {
  17. return obj1 !== 0 || isNegZero(obj1) === isNegZero(obj2);
  18. }
  19. return false;
  20. }
  21. module.exports = identical;