IsStrictlyEqual.js 557 B

1234567891011121314151617181920
  1. 'use strict';
  2. var SameValueNonNumeric = require('./SameValueNonNumeric');
  3. var Type = require('./Type');
  4. var BigIntEqual = require('./BigInt/equal');
  5. var NumberEqual = require('./Number/equal');
  6. // https://262.ecma-international.org/13.0/#sec-isstrictlyequal
  7. module.exports = function IsStrictlyEqual(x, y) {
  8. var xType = Type(x);
  9. var yType = Type(y);
  10. if (xType !== yType) {
  11. return false;
  12. }
  13. if (xType === 'Number' || xType === 'BigInt') {
  14. return xType === 'Number' ? NumberEqual(x, y) : BigIntEqual(x, y);
  15. }
  16. return SameValueNonNumeric(x, y);
  17. };