检测子字符串是否在主字符串的头部。
- Source:
Example
str.startsWith('foobar', 'foo') // true
str.startsWith('foobar', 'boo') // false
str.startsWith('foobar', 'oo', 1) // true
str.startsWith('foobar', 'foo', 0) // true
str.startsWith('foobar', 'foo', 1) // fa;se
str.startsWith(12345, 123) // true
str.startsWith(2345, 123) // false
str.startsWith('', '') // true
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
str |
String | 主字符串 | ||
subStr |
String | 子字符串 | ||
start |
Number |
<optional> |
0
|
开始检测的位置 |
Returns:
true,表示在头部;false,表示不在头部
- Type
- Boolean