1 /**
  2  * @fileOverview This file contains array diff and intersect methods for JS 1.5 to 1.7 (note that JsDoc does not index Array.new.js)
  3  */
  4 
  5 /**
  6  * Compare this array with another one and return an array with all the items
  7  * in this one that are not in the other.
  8  * 
  9  * @param {Array} otherArray The array to compare to
 10  * @return {Array} An array with all items in this array not in otherArray
 11  */
 12 Array.prototype.diff = function diff(otherArray) {
 13 	return this.filter(function(item) {
 14 		return !otherArray.has(item);
 15 	});
 16 };
 17 
 18 /**
 19  * Compare this array with another one and return an array with all the items
 20  * that are in both arrays.
 21  * 
 22  * @param {Array} otherArray The array to compare to
 23  * @return {Array} An array with all items in this array and otherArray
 24  */
 25 Array.prototype.intersect = function intersect(otherArray) {
 26 	return this.filter(function(item) {
 27 		return otherArray.has(item);
 28 	});
 29 };
 30 
 31