js endswith
js中endswith是什么呢?不知道的小伙伴来看看小编今天的分享吧!
1、js中endswit简介:
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 http://github.com/mdn/interactive-examples and send us a pull request.
Syntaxstr.endsWith(searchString[, length])
2、参数:
searchString
要搜索的子字符串。
length
可选。作为 str 的长度。默认值为 str.length。
返回值
如果传入的子字符串在搜索字符串的末尾则返回true;否则将返回 false。
描述
这个方法帮助你确定一个字符串是否在另一个字符串的末尾。这个方法是大小写敏感的。
示例:
使用 endsWith()var str = "To be, or not to be, that is the question.";
alert( str.endsWith("question.") ); // true
alert( str.endsWith("to be") ); // false
alert( str.endsWith("to be", 19) ); // true
Polyfill
这个方法已经加入到 ECMAScript 6 标准当中,但是可能还没有在所有的 JavaScript 实现中可用。然而,你可以通过如下的代码片段扩展 String.prototype.endsWith() 实现兼容:if (!String.prototype.endsWith) {undefined
String.prototype.endsWith = function(search, this_len) {undefined
if (this_len === undefined || this_len > this.length) {undefined
this_len = this.length;
}
return this.substring(this_len - search.length, this_len) === search;
};
}
-
5系点烟器保险丝位置
宝马525i点烟器保险丝在车的右后侧,可以打开查看。根据使用说明可以知道点火器的熔丝安培数。最高的那只黄色的20W。车里可以保留一些,以备随时更换,但是不要试图通过增加保险的保...
问答查看全文>> -
简短腊八节祝福语 腊八节祝福语句子
1、天寒地冻腊八粥,暖暖情谊涌心头。2、将浓浓的亲情掺入腊八粥,翻腾快乐;把甜甜的爱情投入腊八粥,洋溢幸福;将暖暖的友情加入腊八粥,沉积好运。腊八节到,祝身体健康,心情愉快。3...
祝福语查看全文>> -
2019款宝马525真实油耗怎么样?
2019款宝马525真实油耗在13到14个左右,还是挺高的:1、车身尺寸方面,全新一代宝马5系长轴距版车型的长宽高分别为5087mm\/1868mm\/...
问答查看全文>>
推荐
- 1第二年需要交强险吗468
- 2qq性签名霸气女生232
- 3车子起雾看不见怎么办298
- 4b0002故障码解释及消除方法, B0002故障码怎么解决?196
- 5形容一个人大度不计较朋友圈 有深度有涵养的句子395
- 6告别的文案(告别深秋文案美句)186
- 7车辆交强险赔偿范围是什么?221
- 892和95哪个标号汽油耐烧232