es.array.includes.js 720 B

123456789101112131415161718192021
  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. return !Array(1).includes();
  9. });
  10. // `Array.prototype.includes` method
  11. // https://tc39.es/ecma262/#sec-array.prototype.includes
  12. $({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
  13. includes: function includes(el /* , fromIndex = 0 */) {
  14. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  15. }
  16. });
  17. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  18. addToUnscopables('includes');