Javascript String contains(string)

Description

Javascript String contains(string)



/**//from  w w w .  j  a  va 2s  . c o m
 * Checks whether the string contains a given string.
 *
 * @method String.prototype.contains
 * @param {String} string The string to search for
 * @return {Boolean} True if the string contains a given string
 */
String.prototype.contains = function(string) {
    return this.indexOf(string) >= 0;
};

Javascript String contains(string)

String.prototype.contains = function(string) {
  return (this.indexOf(string) != -1);
}



PreviousNext

Related