Skip to content

Latest commit

 

History

History
32 lines (21 loc) · 539 Bytes

README.md

File metadata and controls

32 lines (21 loc) · 539 Bytes

Array.prototype.forEachN()

Pass all array members to a callback function, n members at a time.

Syntax

arr.forEachN(n, callback(...args)[, thisArg])

Parameters

n
Number of elements to pass to callback at a time.

callback
Function to call.

thisArg
A value to bind this to. If not set, this refers to the Array instance.

Returns

undefined.

Example

[1,2,3,4].forEachN(2, (arr) => console.log(arr));
// [ 1, 2 ]
// [ 3, 4 ]