https://github.com/jonschlinkert/array-first
Get the first element or first n elements of an array.
https://github.com/jonschlinkert/array-first
array first javascript nodejs
Last synced: 8 months ago
JSON representation
Get the first element or first n elements of an array.
- Host: GitHub
- URL: https://github.com/jonschlinkert/array-first
- Owner: jonschlinkert
- License: mit
- Created: 2014-12-12T11:06:18.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2021-02-13T22:13:22.000Z (almost 5 years ago)
- Last Synced: 2025-04-19T20:53:50.378Z (9 months ago)
- Topics: array, first, javascript, nodejs
- Language: JavaScript
- Homepage: https://github.com/jonschlinkert
- Size: 8.79 KB
- Stars: 11
- Watchers: 3
- Forks: 14
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-micro-npm-packages - array-first - Get the first element or first n elements of an array. (Modules / Array)
- awesome-micro-npm-packages-zh - array-first - 获取数组的第一个元素或开始的第n个元素. (模块 / 数组)
- awesome-micro-npm-packages - array-first - Get the first element or first n elements of an array. (Modules / Array)
- fucking-awesome-micro-npm-packages - array-first - Get the first element or first n elements of an array. (Modules / Array)
README
# array-first [](https://www.npmjs.com/package/array-first) [](https://travis-ci.org/jonschlinkert/array-first)
> Get the first element or first n elements of an array.
- [Usage](#usage)
- [Related projects](#related-projects)
- [Running tests](#running-tests)
- [Contributing](#contributing)
- [Author](#author)
- [License](#license)
_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_
## Usage
```js
var first = require('array-first');
first(['a', 'b', 'c', 'd', 'e', 'f']);
//=> 'a'
first(['a', 'b', 'c', 'd', 'e', 'f'], 1);
//=> 'a'
first(['a', 'b', 'c', 'd', 'e', 'f'], 3);
//=> ['a', 'b', 'c']
```
## Related projects
[array-last](https://www.npmjs.com/package/array-last): Get the last or last n elements in an array. | [homepage](https://github.com/jonschlinkert/array-last)
## Running tests
Install dev dependencies:
```sh
$ npm i -d && npm test
```
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/array-first/issues/new).
## Author
**Jon Schlinkert**
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright © 2016 [Jon Schlinkert](https://github.com/jonschlinkert)
Released under the MIT license.
***
_This file was generated by [verb](https://github.com/verbose/verb) on January 12, 2016._