unqiue-array

Benchmark created by paul on


Test runner

Ready to run.

Testing in
TestOps/sec
john
Array.prototype.unique = function(){
  return this.filter( function( a ){
    if ( this.indexOf( a ) > -1 ) return false;
    return this.push( a );
  }.bind([]) );
};
ready
preston
function unique(list) {
    return list.reduce(function(uniques, item, index) {
      if (list.indexOf(item, index+1) < 0)
          uniques.push(item);
      return uniques;
    }, []);
}
ready
paul
Array.prototype.unique = function () {
  for (var i=0; i < this.length; i++)
    if (this.indexOf(this[i]) !== i) this.splice(i,1);
  return this;
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.