Created: 2014-12-12 11:06
Updated: 2018-04-25 15:30
License: mit

array-first NPM version Build Status

Get the first element or first n elements of an array.

(TOC generated by verb using markdown-toc)


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: Get the last or last n elements in an array. | homepage

Running tests

Install dev dependencies:

$ npm i -d && npm test


Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.


Jon Schlinkert


Copyright © 2016 Jon Schlinkert Released under the MIT license.

This file was generated by verb on January 12, 2016.

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more