Last change
on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
855 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 | /* eslint-disable es/no-array-prototype-indexof -- required for testing */
|
---|
3 | var $ = require('../internals/export');
|
---|
4 | var $indexOf = require('../internals/array-includes').indexOf;
|
---|
5 | var arrayMethodIsStrict = require('../internals/array-method-is-strict');
|
---|
6 |
|
---|
7 | var nativeIndexOf = [].indexOf;
|
---|
8 |
|
---|
9 | var NEGATIVE_ZERO = !!nativeIndexOf && 1 / [1].indexOf(1, -0) < 0;
|
---|
10 | var STRICT_METHOD = arrayMethodIsStrict('indexOf');
|
---|
11 |
|
---|
12 | // `Array.prototype.indexOf` method
|
---|
13 | // https://tc39.es/ecma262/#sec-array.prototype.indexof
|
---|
14 | $({ target: 'Array', proto: true, forced: NEGATIVE_ZERO || !STRICT_METHOD }, {
|
---|
15 | indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {
|
---|
16 | return NEGATIVE_ZERO
|
---|
17 | // convert -0 to +0
|
---|
18 | ? nativeIndexOf.apply(this, arguments) || 0
|
---|
19 | : $indexOf(this, searchElement, arguments.length > 1 ? arguments[1] : undefined);
|
---|
20 | }
|
---|
21 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.