首页 > Web开发 > 详细

JS endWith

时间:2020-06-02 19:04:05      阅读:37      评论:0      收藏:0      [点我收藏+]

参考地址

代码

String.prototype.endWith = function (endStr) {
    var d = this.length - endStr.length;
    return (d >= 0 && this.lastIndexOf(endStr) == d);
}

调用

var str="I love antzone";
console.log(str.endWith("ne"));

JS endWith

原文:https://www.cnblogs.com/Alex-Mercer/p/13032825.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!