Javascript Array intersect(compare)

Description

Javascript Array intersect(compare)


Array.prototype.intersect = function (compare) {
    var intersect = [];

    for (var i = 0; i < this.length; i++) {
        if (this[i] == compare[i]) {
            intersect.push(this[i]);/*from   w  w w .j  a v  a 2 s .  c  o  m*/
        }
    }

    return intersect;
}



PreviousNext

Related