Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Methods to remove duplicates from array
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:134.0) Gecko/20100101 Firefox/134.0
Browser:
Firefox 134
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
one year ago
Using a Set
521/s
Using indexOf
222/s
Using lastIndexOf
218/s
View exact numbers
Test name
Executions per second
✓
Using a Set
521 Ops/sec
Using indexOf
222 Ops/sec
Using lastIndexOf
218 Ops/sec
Script Preparation code:
var array = []; for (let i = 0; i < 100000; i++) { array.push(Math.floor((Math.random() * 10) + 1)); }
Tests:
Using indexOf
array.filter((item, index) => array.indexOf(item) != index);
Using lastIndexOf
array.filter((item, index) => array.lastIndexOf(item) != index);
Using a Set
[...new Set(array)]