UNPKG

@extra-array/index-of

Version:
55 lines (41 loc) 1.73 kB
Finds first index of a value. [:package:](https://www.npmjs.com/package/@extra-array/index-of) [:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array) [:running:](https://npm.runkit.com/@extra-array/index-of) [:vhs:](https://asciinema.org/a/332064) [:moon:](https://www.npmjs.com/package/@extra-array/index-of.min) [:scroll:](https://unpkg.com/@extra-array/index-of/) [:newspaper:](https://nodef.github.io/extra-array/) [:blue_book:](https://github.com/nodef/extra-array/wiki/) > Alternatives: [indexOf], [lastIndexOf].<br> > Similar: [search], [indexOf], [isValue], [includes]. > This is part of package [extra-array]. [extra-array]: https://www.npmjs.com/package/extra-array <br> ```javascript array.indexOf(x, v, [i]); // x: an array // v: search value // i: start index (0) ``` ```javascript const array = require("extra-array"); var x = [1, 2, 3, 2, 5]; array.indexOf(x, 2); // 1 ^ var x = [1, 2, 3, 2, 5]; array.indexOf(x, 2, 2); // 3 ^ ``` <br> <br> ## References - [List-Extra.elemIndex: elm](https://package.elm-lang.org/packages/elm-community/list-extra/7.1.0/List-Extra#elemIndex) - [Array.prototype.indexOf: MDN web docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf) - [_.indexOf: lodash](https://lodash.com/docs/4.17.15#indexOf) - [Array.indexOf: sugarjs](https://sugarjs.com/docs/#/ES5/Array/indexOf) [indexOf]: https://github.com/nodef/extra-array/wiki/indexOf [lastIndexOf]: https://github.com/nodef/extra-array/wiki/lastIndexOf [search]: https://github.com/nodef/extra-array/wiki/search [isValue]: https://github.com/nodef/extra-array/wiki/isValue [includes]: https://github.com/nodef/extra-array/wiki/includes