Nodejs Array Equal Check isEqual(target)

Here you can find the source of isEqual(target)

Method Source Code

"use strict";// w  w w . j  av  a  2s .com
Array.prototype.isEqual = function(target){
   if (this == target) return true;
   if (this == null || target == null) return false;
   if (this.length != target.length) return false;
   for(var i in this){
      if (
         (this[i] !== target[i]) &&
         (typeof this[i].isEqual != "function" ||
         !this[i].isEqual(target[i]))
      ){
         return false;
      }
   }
   return true;
}

Related

  1. isEqual(a)
    Array.prototype.isEqual = function(a){
      if(this.length!=a.length) return false;
      for(var i=0;i<this.length;i++){
        if(this[i] instanceof Array){
          if(!(a[i] instanceof Array)) return false;
          if(!this[i].isEqual(a[i])) return false;
        }else{
          if(this[i]!=a[i]) return false;
      return true;
    
  2. isEqual(arr)
    const a = [1, 2, 3];
    const b = [1, 2, 3];
    Array.prototype.isEqual = function (arr) {
      function check(arr1, arr2) {
        for (let i = 0, len = arr1.length; i < len; i++) {
          const bool = arr2.some(function (item) {
            return Object.is(arr1[i], item);
          });
          if (!bool) return false;
    ...