UNPKG

@extra-array/head

Version:
49 lines (35 loc) 1.29 kB
Gets first value. [:package:](https://www.npmjs.com/package/@extra-array/head) [:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array) [:running:](https://npm.runkit.com/@extra-array/head) [:vhs:](https://asciinema.org/a/332061) [:moon:](https://www.npmjs.com/package/@extra-array/head.min) [:scroll:](https://unpkg.com/@extra-array/head/) [:newspaper:](https://nodef.github.io/extra-array/) [:blue_book:](https://github.com/nodef/extra-array/wiki/) > Similar: [head], [tail], [init], [last]. > This is part of package [extra-array]. [extra-array]: https://www.npmjs.com/package/extra-array <br> ```javascript array.head(x, [vd]); // x: an array // vd: default value ``` ```javascript const array = require("extra-array"); array.head([1, 2, 3]); // 1 array.head([], -1); // -1 ``` <br> <br> ## References - [Data.List.head: Haskell](https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-List.html#v:head) - [_.head: lodash](https://lodash.com/docs/4.17.15#head) - [Array.first: sugarjs](https://sugarjs.com/docs/#/Array/first) [head]: https://github.com/nodef/extra-array/wiki/head [tail]: https://github.com/nodef/extra-array/wiki/tail [init]: https://github.com/nodef/extra-array/wiki/init [last]: https://github.com/nodef/extra-array/wiki/last