JS endWith

参考地址

代码

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"));
posted @ 2020-06-02 18:06  Alex_Mercer  阅读(3197)  评论(0编辑  收藏  举报