- 0133技术站
- 联系QQ:18840023
- QQ交流群
- 微信公众号
startsWith()方法确定字符串是否以指定字符开头。
语法:
str.startsWith(searchString[, position])
参数:
● searchString:要在此字符串开头搜索的字符。
● Position:此字符串中开始搜索searchString的位置; 默认为0。
返回值:
如果字符串以搜索字符串的字符开头,则为true;否则为false。否则,错误。
例:
var str = 'hello world!!!'; console.log(str.startsWith('hello'));
输出:
true
推荐手册