Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
lodash.compact vs js native
(version: 0)
Remove undefined/null from array
Comparing performance of:
lodash.compact vs array filter
Created:
4 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
var array = ['a', undefined, 'b', 1, undefined, 2, 3, undefined, undefined]
Tests:
lodash.compact
_.compact(array);
array filter
array.filter(data => { return data !== undefined && data !== null });
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
lodash.compact
array filter
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 months ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36
Browser/OS:
Chrome 145 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
lodash.compact
66226748.0 Ops/sec
array filter
77322584.0 Ops/sec
Related benchmarks:
compact function
Lodash compact
Native Undefined vs Lodash isUndefined
isUndefined
Comments
Confirm delete:
Do you really want to delete benchmark?