1.0.0 • Published 8 years ago

a-first v1.0.0

Weekly downloads
9
License
ISC
Repository
github
Last release
8 years ago

a-first

Returns the first n element of an array

Install

$ npm install --save a-first

Example

var first = require('a-first');

var arr = [1, 2, 3, 4, 5];

console.log(first(arr, 2));
// -> [1, 2]

console.log(first(arr));
// -> 1

require('a-first')(array, n)

Arguments:

  • array: The array
  • n: number of first n elements that wants to be returned
  • If we do not mention argument n then function will return first element of array

Returns: Returns the first n element of an array

License

© 2016 vikram. MIT License

1.0.0

8 years ago