Nodejs Array Include includes(target)

Here you can find the source of includes(target)

Method Source Code

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

Related

  1. includes(s)
    Array.prototype.includes = function(s) {
        return this.indexOf(s) > -1;
    };
    
  2. includes(searchElement /*, fromIndex*/ )
    Array.prototype.includes = Array.prototype.includes || (function(searchElement  ) {
      var O = Object(this);
      var len = parseInt(O.length, 10) || 0;
      if (len === 0) return false;
      var n = parseInt(arguments[1], 10) || 0;
      var k;
      if (n >= 0) {
        k = n;
      } else {
    ...
    
  3. includes(searchElement /*, fromIndex*/ )
    if (![].includes) {
      Array.prototype.includes = function(searchElement  ) {
        if (this === undefined || this === null) {
          throw new TypeError('Cannot convert this value to object');
        var O = Object(this);
        var len = parseInt(O.length, 10) || 0;
        if (len === 0) {
          return false;
    ...
    
  4. includes(searchElement /*, fromIndex*/)
    if (!Array.prototype.includes) {
      Array.prototype.includes = function(searchElement ) {
        'use strict';
        if (this == null) {
          throw new TypeError('Array.prototype.includes called on null or undefined');
        var O = Object(this);
        var len = parseInt(O.length, 10) || 0;
        if (len === 0) {
    ...
    
  5. includes(searchElement)
    Array.prototype.includes = function(searchElement) {  
        var O = Object(this);
        var len = parseInt(O.length) || 0;
        if (len === 0) {
          return false;
        var n = parseInt(arguments[1]) || 0;
        var k;
        if (n >= 0) {
    ...
    
  6. includes(target)
    Array.prototype.includes = function(target) {
      for(var i in this) {
        if(this[i] === target) {
          return true;
        };
      };
      return false;
    };
    
  7. includes(val)
    Array.prototype.includes = function (val) {
      var returnValue = false;
      this.forEach(function (el, i){
        if (val === el) {
          returnValue = true;
      });
      return returnValue;
    };
    ...
    
  8. includes(val)
    var bubbleSort = function (arr) {
      var notSorted = true
      while (notSorted) {
        notSorted = false;
        for (var i = 0; i <= arr.length-2; i++) {
          var j = i+1;
          if (arr[j] < arr[i]) {
            var temp = arr[j];
            arr[j] = arr[i];
    ...
    
  9. includes(val, from)
    Array.prototype.includes = function(val, from) {
        return this.indexOf(val, from) !== -1;