Global.Array.intersection ()
retrieve the intersection set of a bunch of arrays

  • Parameter Array:
    (Array2, ...) the arrays to intersect
  • Returns
    Array the intersection set
Sourcecode in /home/hannes/helma/modules/core/Array.js:
44:   Array.intersection = function() {
45:      var all = Array.union.apply(this, arguments);
46:      var result = [];
47:      for (var n in all) {
48:         var chksum = 0;
49:         var item = all[n];
50:         for (var i=0; i<arguments.length; i+=1) {
51:            if (arguments[i].contains(item))
52:               chksum += 1;
53:           else
54:              break;
55:        }
56:        if (chksum == arguments.length)
57:           result.push(item);
58:     }
59:     return result;
60:  }