repl.txt (1629B)
1 2 {{alias}}( val, searchValue[, position] ) 3 Tests if an array-like value contains a search value. 4 5 When `val` is a string, the function checks whether the characters of the 6 search string are found in the input string. The search is case-sensitive. 7 8 When `val` is an array-like object, the function checks whether the input 9 array contains an element strictly equal to the specified search value. 10 11 For strings, this function is modeled after `String.prototype.includes`, 12 part of the ECMAScript 6 specification. This function is different from a 13 call to `String.prototype.includes.call` insofar as type-checking is 14 performed for all arguments. 15 16 The function does not distinguish between positive and negative zero. 17 18 If `position < 0`, the search is performed for the entire input array or 19 string. 20 21 22 Parameters 23 ---------- 24 val: ArrayLike 25 Input value. 26 27 searchValue: any 28 Value to search for. 29 30 position: integer (optional) 31 Position at which to start searching for `searchValue`. Default: `0`. 32 33 Returns 34 ------- 35 bool: boolean 36 Boolean indicating if an input value contains another value. 37 38 Examples 39 -------- 40 > var bool = {{alias}}( 'Hello World', 'World' ) 41 true 42 > bool = {{alias}}( 'Hello World', 'world' ) 43 false 44 > bool = {{alias}}( [ 1, 2, 3, 4 ], 2 ) 45 true 46 > bool = {{alias}}( [ NaN, 2, 3, 4 ], NaN ) 47 true 48 49 // Supply a position: 50 > bool = {{alias}}( 'Hello World', 'Hello', 6 ) 51 false 52 > bool = {{alias}}( [ true, NaN, false ], true, 1 ) 53 false 54 55 See Also 56 -------- 57