@ndhoule/map

Apply a function to a each element of a collection and return a new array of results.

map

Apply a function to a each element of a collection and return a new array of results.

Installation

$ component install ndhoule/map
$ npm install @ndhoule/map

API

map(iterator : Function, collection : Object|Array|string) => Array

Produce a new array by passing each value in the input collectionthrough an iteratorfunction and accumulating the results. The iteratoris passed three arguments: (value, index, collection).

var square = function(x) { return x * x; };

map(square, [1, 2, 3]);
//=> [1, 4, 9]

License

Released under the MIT license.

HomePage

https://github.com/ndhoule/map

Repository

https://github.com/ndhoule/map.git


上一篇:@ndhoule/pick
下一篇:@ndhoule/keys

相关推荐

官方社区

扫码加入 JavaScript 社区