Compare two array - Node.js Array

Node.js examples for Array:Compare Array

Description

Compare two array

Demo Code


Array.prototype.compareArrays = function(arr) {
    if (this.length != arr.length) return false;
    for (var i = 0; i < arr.length; i++) {
        if (this[i].compareArrays) { //likely nested array
            if (!this[i].compareArrays(arr[i])) return false;
            else continue;//from w ww. j  a va  2  s.  c om
        }
        if (this[i] != arr[i]) return false;
    }
    return true;
};

Related Tutorials