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