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"));
原文:https://www.cnblogs.com/Alex-Mercer/p/13032825.html