@rahmatsaeedi/lotide
Version:
A light-weight, simplified, & minified version of Lodash library
25 lines (22 loc) • 725 B
JavaScript
// Takes in two arrays and returns true or false, based on a perfect match.
// jshint esversion : 6
const assertEqual = require('./assertEqual');
const eqArrays = function(array1, array2) {
if (!(array1 instanceof Array) || !(array2 instanceof Array) || (array1.length !== array2.length)) {
return false;
} else {
let index = array1.length;
while (index > 0) {
index --;
if (array1[index] instanceof Array || array2[index] instanceof Array) {
if (!eqArrays(array1[index], array2[index])) {
return false;
}
} else if (array1[index] !== array2[index]) {
return false;
}
}
return true;
}
};
module.exports = eqArrays;