Nodejs Array Include includes(val)

Here you can find the source of includes(val)

Method Source Code

var bubbleSort = function (arr) {
  var notSorted = true
  while (notSorted) {
    notSorted = false;//from  www  .  ja  v  a  2s .com
    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];
        arr[i] = temp;
        notSorted = true;
      }
    };
  }

  return arr
};


Array.prototype.includes = function (val) {
  var returnValue = false;
  this.forEach(function (el, i){
    if (val === el) {
      returnValue = true;
    }
  });
  return returnValue;
};

var substrings = function (string) {
  var substringsArr = [];

  for (var i = 0; i < string.length; i++) {
    for (var j = i + 1; j <= string.length; j++) {
      var sub = string.substr(i, j - i);
      if (!substringsArr.includes(sub)) {
        substringsArr.push(sub);
      }
    };
  };

  return substringsArr;
};

Related

  1. 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) {
    ...
    
  2. 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) {
    ...
    
  3. includes(target)
    Array.prototype.includes = function (target) {
      var result = false
      this.forEach(function (el) {
        if (el == target) {
          result = true
      });
      return result;
    
  4. includes(target)
    Array.prototype.includes = function(target) {
      for(var i in this) {
        if(this[i] === target) {
          return true;
        };
      };
      return false;
    };
    
  5. includes(val)
    Array.prototype.includes = function (val) {
      var returnValue = false;
      this.forEach(function (el, i){
        if (val === el) {
          returnValue = true;
      });
      return returnValue;
    };
    ...
    
  6. includes(val, from)
    Array.prototype.includes = function(val, from) {
        return this.indexOf(val, from) !== -1;
    
  7. includes(value)
    window.IS_ELECTRON = window.process ? true : false
    if (!window.IS_ELECTRON)
      window.require = () => ({})
    Array.prototype.includes = function(value) {
      return this.some(element => element === value)
    
  8. includes(value)
    Array.prototype.includes = function(value) {
        return jQuery.inArray(value, this) > -1;
    
  9. includes(value)
    Array.prototype.includes = function(value) {
      for (var i=0; i < this.length; i++) {
        if (this[i] === value) {
          return true;
      return false;
    Array.prototype.myUniq = function() {
    ...