字符串startswith
Check if a string starts with the value of the string passed as parameter.
检查字符串是否以作为参数传递的字符串的值开头。
You can call startsWith()
on any string, provide a substring, and check if the result returns true
or false
:
您可以在任何字符串上调用startsWith()
,提供一个子字符串,然后检查结果是否返回true
或false
:
'testing'.startsWith('test') //true
'going on testing'.startsWith('test') //false
This method accepts a second parameter, which lets you specify at which character you want to start checking:
此方法接受第二个参数,该参数可让您指定要开始检查的字符:
'testing'.startsWith('test', 2) //false
'going on testing'.startsWith('test', 9) //true
字符串startswith