JavaScript兑现startWith、endWith效果函数

JavaScript实现startWith、endWith效果函数利用正则表达式实现:String.prototype.endWithfunction(str){va

JavaScript实现startWith、endWith效果函数
利用正则表达式实现:

String.prototype.endWith=function(str){    var reg=new RegExp(str+"$");    return reg.test(this);     }