Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Object.values vs _.values
(version: 0)
Comparing performance of:
JS values vs lodash
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 tmp = {first: {test: 'h', test2: () => {}}, second: {test: () => {}, test2: ''}};
Tests:
JS values
Object.values(tmp).some(i => typeof i.test === 'function');
lodash
_.values(tmp).some(i => typeof i.test === 'function');
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
JS values
lodash
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
llama3.2:3b
, generated one year ago):
Let's dive into the world of JavaScript microbenchmarks on MeasureThat.net. **Benchmark Overview** The benchmark compares the performance of two approaches to access and check the properties of objects: `Object.values` (native JavaScript) and `_values` (from the Lodash library). **Options Compared** Two options are being compared: 1. **Native JavaScript**: Using `Object.values(tmp)` to access the values of an object (`tmp`) and then checking if any of these values have a function property using `some()`. 2. **Lodash Library**: Using `_values(tmp)` to access the values of an object (`tmp`) from Lodash, and then checking if any of these values have a function property using `some()`. **Pros and Cons** **Native JavaScript:** Pros: * No additional dependencies or overhead. * Typically faster since it's native code. * Easier to understand and implement for those familiar with the standard library. Cons: * May not work consistently across all environments (e.g., older browsers, Node.js versions). * Requires manual handling of edge cases (e.g., empty objects). **Lodash Library:** Pros: * Simplifies the process by abstracting away some complexities. * Works in more environments since it's a library that provides a standardized interface. Cons: * Adds an extra dependency and potential overhead. * May have slower performance due to the abstraction layer. **Library Used (Lodash)** Lodash is a popular JavaScript utility library created by Isaac Schankman in 2011. Its primary purpose is to provide a consistent set of functions that make common tasks easier, such as array manipulation, function execution, and object iteration. In this benchmark, Lodash's `_values()` function is used to access the values of an object. **Special JS Feature/Syntax** None mentioned explicitly in the provided information. However, it's worth noting that `some()` is a standard JavaScript method (ECMA-262 5th edition) that can be used to test for any element in an array or iterable satisfying a predicate. This feature is widely supported across modern browsers and Node.js versions. **Other Alternatives** If you're interested in exploring alternative approaches, here are a few options: * **For...of Loop**: Instead of using `Object.values()` or `_values()`, you can use a for-of loop to iterate over the object's properties. * **Array.prototype.map()**: You could also convert the object's values into an array and then apply `map()` to create a new array with function results. Keep in mind that each approach has its trade-offs, and performance may vary depending on the specific use case. MeasureThat.net helps you compare these approaches in a controlled environment.
Related benchmarks:
lodash.values vs Object.values
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?