String.includes()

if (!String.prototype.includes) {
  String.prototype.includes = function(search, start) {
    'use strict';
    if (typeof start !== 'number') {
      start = 0;
    }
    if (start + search.length > this.length) {
      return false;
    } else {
      return this.indexOf(search, start) !== -1;
    }

  };
}

posted @ 2017-07-17 17:53  凉生丿墨染  阅读(428)  评论(0编辑  收藏  举报