string.indexOf()
'abc'.indexOf(substr, [fromIndex]) → number
Returns the index of the first occurrence of a substring, or −1 if not found.
Arguments
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| substr | string | yes | — | Substring to search for. |
| fromIndex | number | optional | 0 | Index to start searching from. |
Returns
number
Index of the first occurrence, or −1 if not found.
Example
'abc'.indexOf('bc') === 1;