Nodejs Array Include includes(searchElement /*, fromIndex*/ )

Here you can find the source of includes(searchElement /*, fromIndex*/ )

Method Source Code

Array.prototype.includes = Array.prototype.includes || (function(searchElement /*, fromIndex*/ ) {
   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;/*from  w  w w .jav a  2 s.  com*/
   if (n >= 0) {
      k = n;
   } else {
      k = len + n;
      if (k < 0) k = 0;
   }
   for (;k < len; k++) if (searchElement === O[k]) return true;
   return false;
});

Related

  1. includes(array)
    Array.prototype.includes = function(array) {
      for ( var i = 0; i < this.length; i++) {
        for ( var k = 0; k < array.length; k++) {
          if ( this[i] == array[k]) {
            return true;
      return false;
    ...
    
  2. includes(element)
    Array.prototype.includes = function(element) {
      return this.indexOf(element) !== -1;
    };
    
  3. includes(item)
    Array.prototype.includes = function(item) {
        return this.indexOf(item) > -1;
    
  4. includes(matcher)
    Array.prototype.includes = function(matcher) {
      var includes = false
        , arr = this;
      for( var j = 0, str; str = arr[j++]; ) {
        if( typeof str === "string" && str.includes(matcher) ) {
          includes = true;
      return includes;
    ...
    
  5. includes(s)
    Array.prototype.includes = function(s) {
        return this.indexOf(s) > -1;
    };
    
  6. 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;
    ...
    
  7. 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) {
    ...
    
  8. 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) {
    ...
    
  9. includes(target)
    Array.prototype.includes = function (target) {
      var result = false
      this.forEach(function (el) {
        if (el == target) {
          result = true
      });
      return result;