Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash values vs Object.values
(version: 0)
Comparing performance of:
Lodash vs Native
Created:
5 years ago
by:
Guest
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 value = {a: 30310, b: 100303, c: 3040494};
Tests:
Lodash
_.values(value)
Native
Object.values(value)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Lodash
Native
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
4 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Browser/OS:
Chrome 143 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash
15626276.0 Ops/sec
Native
37463500.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the benchmark and explain what's being tested. **Benchmark Overview** The benchmark compares the performance of two approaches to extract values from an object: using the Lodash library (`_.values(value)`) versus the native `Object.values()` method. **Options Compared** Two options are being compared: 1. **Lodash**: Using the Lodash library's `_.values()` method to access the values of the `value` object. 2. **Native**: Using the native `Object.values()` method to access the values of the `value` object. **Pros and Cons** Here are some pros and cons of each approach: * **Lodash**: + Pros: Lodash is a well-maintained, widely-used library that provides a simple and consistent API for accessing array-like objects. + Cons: It introduces an extra dependency (the Lodash library) and may incur additional overhead due to the need to load the library and its dependencies. * **Native**: + Pros: The native `Object.values()` method is a lightweight, built-in function that doesn't introduce any additional dependencies. + Cons: It's only available in modern browsers (not older browsers), and its API may not be as consistent or convenient as Lodash. **Other Considerations** When choosing between these two approaches, consider the following: * If you need to support older browsers, the native `Object.values()` method might not be an option. * If you prioritize simplicity and consistency in your code, Lodash might be a better choice. * If you're concerned about additional dependencies or overhead, the native `Object.values()` method is a lightweight alternative. **Library (Lodash)** The Lodash library is a popular JavaScript utility library that provides a wide range of functions for tasks such as array manipulation, string processing, and object transformation. The `_.values()` method is one of its many utility functions that can be used to access the values of an array-like object. **Special JS Feature or Syntax (Not Applicable)** There are no special JavaScript features or syntaxes being tested in this benchmark. **Benchmark Preparation Code** The script preparation code includes: ```javascript var value = {a: 30310, b: 100303, c: 3040494}; ``` This sets up a simple object `value` with three properties and their corresponding values. The HTML preparation code includes the script tag that loads the Lodash library: ```html <script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script> ``` **Other Alternatives** If you're looking for alternative ways to access object values, consider using: * The `for...in` loop: `for (var key in value) { console.log(key + ': ' + value[key]); }` * The `Object.keys()` method: `Object.keys(value).forEach(function(key) { console.log(key + ': ' + value[key]); });` However, these approaches are generally less efficient and more verbose than the native `Object.values()` method or Lodash's `_.values()` method.
Related benchmarks:
lodash.keys [4.17.11] vs Object.keys
lodash.values vs Object.values
Get values from object
Native Object.values().some() vs lodash _.some()
Comments
Confirm delete:
Do you really want to delete benchmark?