JS endWith

时间:2020-06-02 19:02:49   收藏:0   阅读:63

参考地址

代码

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"));
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!