array-method-has-species-support.js 692 B

1234567891011121314151617181920
  1. 'use strict';
  2. var fails = require('../internals/fails');
  3. var wellKnownSymbol = require('../internals/well-known-symbol');
  4. var V8_VERSION = require('../internals/environment-v8-version');
  5. var SPECIES = wellKnownSymbol('species');
  6. module.exports = function (METHOD_NAME) {
  7. // We can't use this feature detection in V8 since it causes
  8. // deoptimization and serious performance degradation
  9. // https://github.com/zloirock/core-js/issues/677
  10. return V8_VERSION >= 51 || !fails(function () {
  11. var array = [];
  12. var constructor = array.constructor = {};
  13. constructor[SPECIES] = function () {
  14. return { foo: 1 };
  15. };
  16. return array[METHOD_NAME](Boolean).foo !== 1;
  17. });
  18. };