unique

JavaScript performance comparison

Test case created by remy

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  const a = [1,2,3,3,3,4,5,5,6,6];

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
reduce spread
a.reduce((acc, curr) => (!acc.includes(curr) ? [...acc, curr] : acc), [])
pending…
from new set
Array.from(new Set(a))
pending…
reduce concat
a.reduce((acc, curr) => (!acc.includes(curr) ? acc.concat(curr) : acc), [])
pending…
filter
a.filter((curr, i) => a.indexOf(curr) === i)
pending…
reduce push
a.reduce((acc, curr) => (!acc.includes(curr) && acc.push(curr) && acc || acc), [])
pending…
filter self
a.filter((curr, i, self) => self.indexOf(curr) === i)
pending…
object based
d={}; a.forEach(function(x) { d[x]=true; }); Object.keys(d);
pending…
spread set
[...new Set(a)]
pending…

Compare results of other browsers

Revisions

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

0 Comments