Javascript String has(str, ignoreCase = true)

Description

Javascript String has(str, ignoreCase = true)


String.prototype.has = function (str, ignoreCase = true) {
  var thisStr = this.toString()
  if (ignoreCase) {
    thisStr = thisStr.toLowerCase()/* www  . j a  v  a  2  s  . c o m*/
    if (str) str = str.toLowerCase()
  }
  return thisStr.indexOf(str) !== -1;
}



PreviousNext

Related