Array.unique

This Array extension will return an array of elements striping out duplicates.
It works by creating an Object with the key and value being the array item, thus causing duplicates to be overwritten.
The Object is then itereated and it's items are pushed to the returned array.

JavaScript

/**
 * Author: Samer Ziadeh
 * http://www.samerziadeh.com/experiments/array.unique
 */
Array.prototype.unique = function ( ) {
    var obj = { }, arr = [ ], i = 0, n;
    for ( i = 0 ; n = this[i++]; ) {
        obj[n] = n;
    }
    for ( n in obj ) {
        arr.push(n);
    }
    return arr;
};
JavaScript Source