Function: includesValue()
ts
function includesValue<T>(
collection,
value,
position?): boolean;Checks whether an array or string includes a value. 检查数组或字符串中是否包含指定值。
Type Parameters
| Type Parameter | Description |
|---|---|
T | The array item type / 数组元素类型 |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
collection | string | readonly T[] | undefined | The array or string to search / 要搜索的数组或字符串 |
value | string | T | undefined | The value to search for / 要搜索的值 |
position | number | 0 | The start position / 起始搜索位置 |
Returns
boolean
true when the value is found / 找到目标值时返回 true
Example
ts
includesValue([1, 2, 3], 2)
// => trueSince
1.2.0