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"));
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"));