- 0133技术站
- 联系QQ:18840023
- QQ交流群
- 微信公众号
endsWith()方法确定字符串是否以另一个字符串的字符结尾。
语法:
str.endsWith(matchstring[, position])
参数:
● matchstring - 字符串必须以字符结尾的字符。它区分大小写。
● Position - 检查匹配字符串的位置。此参数是可选的。
返回值:
如果字符串以匹配字符串的字符结尾,则为true;否则为false。
例:
var str = 'Hello World !!! '; console.log(str.endsWith('Hello')); console.log(str.endsWith('Hello',5));
输出:
false true
推荐手册