Javascript Array has(value)

Description

Javascript Array has(value)




Array.prototype.has = function(value) {
  return (this.indexOf(value) > -1);
}

//remvoe function
Array.prototype.remove = function() {
  var what, a = arguments,
    L = a.length,//from  w  w  w  .j  a  va  2  s.co m
    ax;
  while (L && this.length) {
    what = a[--L];
    while ((ax = this.indexOf(what)) !== -1) {
      this.splice(ax, 1);
    }
  }
  return this;
};

String.prototype.escape = function() {
  var escape = document.createElement('textarea');
  escape.textContent = this;
  return escape.innerHTML;
}

String.prototype.replaceAll = function(search, replacement) {
    var target = this;
    return target.split(search).join(replacement);
};

Javascript Array has(value)

Array.prototype.has = function(value) {
  return (this.indexOf(value) > -1);
}



PreviousNext

Related