endsWith()方法用来判断当前字符串是否是以另外一个给定的子字符串“结尾”的,根据判断结果返回 true 或 false。The source for this interactive example is stored in a GitHub repository. If you’d like to contribute to the interactive examples project, please clone https://github.com/mdn/...
通过向方法传递字符串的新长度,您可以给搜索该索引的字符串赋予新的长度。 让我们看一下使用MDN在文档中提供的长度参数的示例 代码语言:javascript 代码运行次数:0 复制Cloud Studio 代码运行 let str = 'To be, or not to be, that is the question.' console.log(str.endsWith('to be', 19)) // true...
Shauna - Google 员工更新 - 看起来 ECMA6 添加了此功能。 MDN 文章还显示了一种填充物。 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith TJ Crowder - 在现代浏览器上创建子串并不昂贵; 它可能是在 2010 年这个答案发布时。现在,简单的this.substr(-suf...