repl.txt (1205B)
1 2 {{alias}}( collection, predicate[, thisArg ] ) 3 Tests whether all elements in a collection pass a test implemented by a 4 predicate function, iterating from right to left. 5 6 The predicate function is provided three arguments: 7 8 - `value`: collection value 9 - `index`: collection index 10 - `collection`: the input collection 11 12 The function immediately returns upon encountering a non-truthy return 13 value. 14 15 If provided an empty collection, the function returns `true`. 16 17 Parameters 18 ---------- 19 collection: Array|TypedArray|Object 20 Input collection over which to iterate. If provided an object, the 21 object must be array-like (excluding strings and functions). 22 23 predicate: Function 24 The test function. 25 26 thisArg: any (optional) 27 Execution context. 28 29 Returns 30 ------- 31 bool: boolean 32 The function returns `true` if the predicate function returns a truthy 33 value for all elements; otherwise, the function returns `false`. 34 35 Examples 36 -------- 37 > function positive( v ) { return ( v > 0 ); }; 38 > var arr = [ 1, 2, 3, 4 ]; 39 > var bool = {{alias}}( arr, positive ) 40 true 41 42 See Also 43 -------- 44