uniq() -> newArray

Produces a duplicate-free version of an array. If no duplicates are found, the original array is returned.


['Sam', 'Justin', 'Andrew', 'Dan', 'Sam'].uniq();
// -> ['Sam', 'Justin', 'Andrew', 'Dan']

['Prototype', 'prototype'].uniq();
// -> ['Prototype', 'prototype'] because String comparison is case-sensitive

Performance considerations

On large arrays with duplicates, this method has a potentially large performance cost:

More efficient implementations could be devised. This page will get updated if such an optimization is committed.