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 (Android 14; Mobile; rv:135.0) Gecko/135.0 Firefox/135.0
Browser:
Firefox Mobile 135
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
Using indexOf
114.3 Ops/sec
Using lastIndexOf
113.8 Ops/sec
Using a Set
380.0 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)]