Javascript Array includes(target)

Description

Javascript Array includes(target)


Array.prototype.includes = function (target) {
  var result = false
  this.forEach(function (el) {
    if (el == target) {
      result = true/* www. j  a  va2 s  .c  o  m*/
    }
  });
  return result;
}

Javascript Array includes(target)

"use strict";//from  w  w w.  ja  va 2 s  . c  om

Array.prototype.includes = function(target) {
  for(var i in this) {
    if(this[i] === target) {
      return true;
    };
  };
  return false;
};



PreviousNext

Related