String.prototype.endsWith()
String 值的 endsWith() 方法确定字符串是否以此字符串的字符结尾,并根据需要返回 true 或 false。
¥The endsWith() method of String values determines whether a string ends with the characters of this string, returning true or false as appropriate.
Try it
语法
参数
¥Parameters
searchString-
要搜索的字符位于
str末尾。不能 是一个正则表达式。所有非正则表达式的值都是 强制为字符串,因此省略它或传递undefined会导致endsWith()搜索字符串"undefined",这很少是你想要的。 endPositionOptional-
预计找到
searchString的结束位置(searchString最后一个字符的索引加 1)。默认为str.length。
返回值
例外情况
描述
示例
使用 endsWith()
规范
| Specification |
|---|
| ECMAScript Language Specification # sec-string.prototype.endswith |
浏览器兼容性
BCD tables only load in the browser