Nodejs Utililty Methods Array Equal Check

List of utility methods to do Array Equal Check

Description

The list of methods to do Array Equal Check are organized into topic(s).

Method

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;
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;
...
isEqual(target)
"use strict";
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" ||
...