Javascript String include(pattern)

Description

Javascript String include(pattern)


String.prototype.include = function(pattern) {
  return this.indexOf(pattern) > -1;
};

Javascript String include(pattern)

/**/* w w  w  .  j  a v  a  2 s.c om*/
 *  String#include(substring) -> Boolean
 *
 *  Checks if the string contains `substring`.
 *
 *  ##### Example
 *
 *      'Prototype framework'.include('frame');
 *      //-> true
 *      'Prototype framework'.include('frameset');
 *      //-> false
**/
String.prototype.include = function(pattern) {
  return this.indexOf(pattern) !== -1;
}



PreviousNext

Related