UNPKG

@extra-array/index

Version:
51 lines (36 loc) 1.29 kB
Gets zero-based index. [:package:](https://www.npmjs.com/package/@extra-array/index) [:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array) [:running:](https://npm.runkit.com/@extra-array/index) [:vhs:](https://asciinema.org/a/332063) [:moon:](https://www.npmjs.com/package/@extra-array/index.min) [:scroll:](https://unpkg.com/@extra-array/index/) [:newspaper:](https://nodef.github.io/extra-array/) [:blue_book:](https://github.com/nodef/extra-array/wiki/) > Similar: [index], [indexRange], [size], [isEmpty]. > This is part of package [extra-array]. [extra-array]: https://www.npmjs.com/package/extra-array <br> ```javascript array.index(x, [i]); // x: an array // i: index (-ve: from right) (0) ``` ```javascript const array = require("extra-array"); var x = [2, 4, 6, 8]; array.index(x, 1); // 1 array.index(x, -1); // 3 array.index(x, -10); // 0 ``` <br> <br> ## References - [Array.prototype.slice: MDN web docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) [index]: https://github.com/nodef/extra-array/wiki/index [indexRange]: https://github.com/nodef/extra-array/wiki/indexRange [size]: https://github.com/nodef/extra-array/wiki/size [isEmpty]: https://github.com/nodef/extra-array/wiki/isEmpty