I believe intersection method would be good extension to the Array
class. There is combine method (set sum) but no set intersection.

It could look like this:

Array.implement({
    attest: function(item, array) {
        if (!array.contains(item)) this.erase(item);
        return this;
    },
    intersection: function(array) {
        for (var i = 0, l = this.length; i < l; i++)
this.attest(this[i], array);
        return this;
    }
});

What You think?

Reply via email to