|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
715 bytes
|
| Rev | Line | |
|---|
| [a762898] | 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|---|
| 4 |
|
|---|
| 5 | const isArrayLike = require('../predicate/isArrayLike.js');
|
|---|
| 6 |
|
|---|
| 7 | function indexOf(array, searchElement, fromIndex) {
|
|---|
| 8 | if (!isArrayLike.isArrayLike(array)) {
|
|---|
| 9 | return -1;
|
|---|
| 10 | }
|
|---|
| 11 | if (Number.isNaN(searchElement)) {
|
|---|
| 12 | fromIndex = fromIndex ?? 0;
|
|---|
| 13 | if (fromIndex < 0) {
|
|---|
| 14 | fromIndex = Math.max(0, array.length + fromIndex);
|
|---|
| 15 | }
|
|---|
| 16 | for (let i = fromIndex; i < array.length; i++) {
|
|---|
| 17 | if (Number.isNaN(array[i])) {
|
|---|
| 18 | return i;
|
|---|
| 19 | }
|
|---|
| 20 | }
|
|---|
| 21 | return -1;
|
|---|
| 22 | }
|
|---|
| 23 | return Array.from(array).indexOf(searchElement, fromIndex);
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | exports.indexOf = indexOf;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.