es.array.includes.js 794 B

12345678910111213141516171819202122
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var $includes = require('../internals/array-includes').includes;
  4. var fails = require('../internals/fails');
  5. var addToUnscopables = require('../internals/add-to-unscopables');
  6. // FF99+ bug
  7. var BROKEN_ON_SPARSE = fails(function () {
  8. // eslint-disable-next-line es/no-array-prototype-includes -- detection
  9. return !Array(1).includes();
  10. });
  11. // `Array.prototype.includes` method
  12. // https://tc39.es/ecma262/#sec-array.prototype.includes
  13. $({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
  14. includes: function includes(el /* , fromIndex = 0 */) {
  15. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  16. }
  17. });
  18. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  19. addToUnscopables('includes');