repl.txt (1203B)
1 2 {{alias}}( collection, predicate[, thisArg ] ) 3 Tests whether at least one element in a collection passes a test implemented 4 by a 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 truthy return value. 13 14 If provided an empty collection, the function returns `false`. 15 16 Parameters 17 ---------- 18 collection: Array|TypedArray|Object 19 Input collection over which to iterate. If provided an object, the 20 object must be array-like (excluding strings and functions). 21 22 predicate: Function 23 The test function. 24 25 thisArg: any (optional) 26 Execution context. 27 28 Returns 29 ------- 30 bool: boolean 31 The function returns `true` if the predicate function returns `true` for 32 any element; otherwise, the function returns `false`. 33 34 Examples 35 -------- 36 > function negative( v ) { return ( v < 0 ); }; 37 > var arr = [ -1, 1, 2, 3, 4 ]; 38 > var bool = {{alias}}( arr, negative ) 39 true 40 41 See Also 42 -------- 43