From my XArray mixin class (all 3 are needed). /** * Returns a new array by removing duplicate values in Array. */ Array.prototype.uniq = function() { var r = []; var l = this.length; for (var a = 0; a < l; a++) { if (!r.has(this[a])) r.push(this[a]); } return r; };
/** * An array is equal to another array if the lengths are equal and each * corresponding element is equal */ Array.prototype.eql = function(arr) { if (arr.length != this.length || !(arr instanceof Array)) { return false; } else { var a = this.length; while (--a -(-1)) { if (this[a] instanceof Array) { if (!this[a].eql(arr[a])) return false; } else if (this[a] != arr[a]) { return false; } } } return true; }; /** * Returns true if the given obj is present in Array * (if any element == obj) */ Array.prototype.has = function(obj) { var a = this.length; if (!(obj instanceof Array)) { while (--a -(-1)) { if (this[a] == obj) return true; } } else { while (--a -(-1)) { if (this[a].eql(obj)) return true; } } return false; }; http://ubergeek.tv/XArray/XArray.as _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com