startsWith()方法用来判断当前字符串是否是以另外一个给定的子字符串“开头”的,根据判断结果返回 true 或 false。
参数:
str.startsWith(searchString [, position]);
searchString
要搜索的子字符串。
position
在 str 中搜索 searchString 的开始位置,默认值为 0,也就是真正的字符串开头处。
示例:
var str = "To be, or not to be, that is the question.";
alert(str.startsWith("To be")); // true
alert(str.startsWith("not to be")); // false
alert(str.startsWith("not to be", 10)); // true
最后
以上就是无辜棒球最近收集整理的关于startsWith()方法的全部内容,更多相关startsWith()方法内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复