String.prototype.endWith=function(str){ var reg=new RegExp(str+"$"); return reg.test(this); }JavaScript实现startWith、endWith效果函数 代码如下: