Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Set vs some for arrays of objects
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Browser:
Chrome 119
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Set
35542.2 Ops/sec
Some
401.3 Ops/sec
Script Preparation code:
var arr = new Array(1000).fill({ field1: Math.ceil(Math.random() * 1000) }); var arr2 = new Array(1000).fill({ field2: Math.ceil(Math.random() * 1000) });
Tests:
Set
const set = new Set(arr.map((el) => el.field1)); const result = arr2.filter(el => set.has(el.field2));
Some
const result = arr2.filter(el => arr.some((i) => el.field2 === i.field1));