Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Filter out null and map nested object with flatMap() vs map().filter()
flatMap vs filter map
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:138.0) Gecko/20100101 Firefox/138.0
Browser:
Firefox 138
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
map().filter()
16.7 Ops/sec
flatMap()
11.8 Ops/sec
filter().map()
15.2 Ops/sec
Script Preparation code:
var arr = []; var id = 0; while (id <= 1_000_000) { id++; arr[id] = id % 10 === 0 ? { id, data: null } : { id, data: { id } }; }
Tests:
map().filter()
arr.map(it => it.data).filter(it => it !== null)
flatMap()
arr.flatMap(it => it.data != null ? [it.data] : [])
filter().map()
arr.filter(it => it.data !== null).map(it => it.data)