Javascript String includes(search, start)

Description

Javascript String includes(search, start)


String.prototype.includes = function(search, start) {
  'use strict';//from ww w  .j  a  v  a2s.c o  m
  if (typeof start !== 'number') {
    start = 0;
  }

  if (start + search.length > this.length) {
    return false;
  } else {
    return this.indexOf(search, start) !== -1;
  }
};



PreviousNext

Related