repl.txt (930B)
1 2 {{alias}}( collection, fcn[, thisArg] ) 3 Invokes a function for each element in a collection. 4 5 When invoked, the input function is provided three arguments: 6 7 - `value`: collection value 8 - `index`: collection index 9 - `collection`: the input collection 10 11 Parameters 12 ---------- 13 collection: Array|TypedArray|Object 14 Input collection over which to iterate. If provided an object, the 15 object must be array-like (excluding strings and functions). 16 17 fcn: Function 18 The function to invoke for each element in a collection. 19 20 thisArg: any (optional) 21 Execution context. 22 23 Returns 24 ------- 25 out: Array|TypedArray|Object 26 Input collection. 27 28 Examples 29 -------- 30 > function logger( v, i ) { console.log( '%s: %d', i, v ); }; 31 > var arr = [ 1, 2, 3, 4 ]; 32 > {{alias}}( arr, logger ) 33 0: 1 34 1: 2 35 2: 3 36 3: 4 37 38 See Also 39 -------- 40