Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
lodash _.map vs native map
(version: 0)
Comparing performance of:
_.map vs native
Created:
5 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.core.js"></script>
Script Preparation code:
var array = [{id: 'a'}, {id: 'c'}, {id: 'b'}]
Tests:
_.map
_.map(array, a => console.log(a.id))
native
array.map(a => console.log(a.id))
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
_.map
native
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
gemma2:9b
, generated one year ago):
This benchmark tests the performance of two different methods for iterating over an array and logging each item's `id` property: * **`lodash _.map()`:** This utilizes the `_.map()` function from the Lodash library. Lodash is a popular JavaScript utility library that offers a wide range of functions to simplify common tasks, including working with arrays. * **`native map()`:** This uses the built-in `map()` method available in modern JavaScript. **Options Compared:** The benchmark directly compares the execution speed (executions per second) of both methods. **Pros/Cons:** * **`lodash _.map()`:** * **Pro:** Potentially more readable if you are already using Lodash for other tasks, as it offers a consistent syntax across different operations. * **Con:** Introduces an external dependency (Lodash) which can increase bundle size and potentially slow down initial page load. * **`native map()`:** * **Pro:** No additional dependencies, resulting in smaller bundle sizes and faster initial loading times. * **Con:** Might require slightly more code if you are not familiar with the built-in `map()` method syntax. **Other Considerations:** * **Library Usage:** If your project already utilizes Lodash, using `_.map()` might be a more convenient choice due to consistency in coding style and familiarity. * **Performance Sensitivity:** In performance-critical applications, benchmarking specific operations like array iteration is crucial. Even small differences can have noticeable impacts on overall application speed. **Alternatives:** * **`forEach()`:** While not directly compared in this benchmark, `forEach()` is another common method for iterating over arrays. It executes a provided function for each element but doesn't return a new array. It's generally less performant than `map()` if you need the result as a new array. Let me know if you have any other questions about this benchmark or JavaScript performance in general!
Related benchmarks:
array.map vs _.map
lodash _.map vs native map true version
native map vs lodash map on large array
Array Map Vs Lodash Map (1)
Comments
Confirm delete:
Do you really want to delete benchmark?