String.prototype.endsWith(searchString, endPosition = searchString.length)
此函数确定字符串是否以另一个字符串的字符结尾。
语法 (Syntax)
str.endsWith(matchstring[, position])
参数 (Parameters)
matchstring - 字符串必须以的字符结尾。 它区分大小写。
Position - 匹配matchstring的位置。 此参数是可选的。
返回值 (Return Value)
如果字符串以匹配字符串的字符结尾,则为true否则为true 。 否则,是的。
例子 (Example)
var str = 'Hello World !!! ';
console.log(str.endsWith('Hello'));
console.log(str.endsWith('Hello',5));
输出 (Output)
false
true