starsWidth 和endWidth ie不兼容方案

if (typeof String.prototype.startsWith != 'function') {
  String.prototype.startsWith = function (prefix){
  return this.slice(0, prefix.length) === prefix;
  };
}

 

if (typeof String.prototype.endsWith != 'function') {
 String.prototype.endsWith = function(suffix) {
 return this.indexOf(suffix, this.length - suffix.length) !== -1;
 };
}

 

posted @ 2018-11-07 18:00  Samsara315  阅读(185)  评论(0编辑  收藏  举报