UNPKG

@extra-array/length

Version:
53 lines (38 loc) 1.48 kB
Counts the number of values. [:package:](https://www.npmjs.com/package/@extra-array/length) [:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array) [:running:](https://npm.runkit.com/@extra-array/length) [:vhs:](https://asciinema.org/a/332092) [:moon:](https://www.npmjs.com/package/@extra-array/length.min) [:scroll:](https://unpkg.com/@extra-array/length/) [: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.length(x, [i], [I]); // x: an array // i: start index (-ve: from right) (0) // I: end index (-ve: from right) (X) ``` ```javascript const array = require("extra-array"); var x = [2, 4, 6, 8]; array.length(x); // 4 array.length(x, 1); // 3 array.length(x, 1, 3); // 2 ``` <br> <br> ## References - [Array.prototype.slice: MDN web docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) - [Array.length: MDN web docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length) [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