Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Object values vs _.values (underscore)
(version: 0)
Compare the built-in Object.values() method vs Underscore's _.values() method
Comparing performance of:
Object values vs _.values
Created:
4 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js'></script>
Tests:
Object values
var a = { a: 1, b: 2, c: 3 }; Object.values(a);
_.values
var a = { a: 1, b: 2, c: 3 }; _.values(a);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Object values
_.values
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. **What is being tested?** The provided JSON represents two test cases that compare the performance of the built-in `Object.values()` method versus Underscore.js's `_.values()` method. **Options compared:** 1. **Built-in `Object.values()`**: This method returns an array of values for each enumerable property returned in the specified object. 2. **Underscore.js's `_.values()`**: This function returns an array containing all the values of an object, similar to the built-in method. **Pros and Cons:** * Built-in `Object.values()`: + Pros: Native JavaScript implementation, high performance, easy to use. + Cons: May not support older browsers or versions of JavaScript that don't have this method. * Underscore.js's `_.values()`: + Pros: Widespread adoption and compatibility with many browsers and JavaScript versions. Easy to include in projects due to its small size. + Cons: External dependency, may introduce overhead due to the library. **Other considerations:** When choosing between these two options, consider the following factors: * Browser support: If you need to support older browsers or specific versions of JavaScript that don't have `Object.values()`, Underscore.js's `_.values()` might be a better choice. * Performance: If raw performance is crucial, the built-in `Object.values()` method will likely be faster due to its native implementation. * Library size and dependencies: If you're working on a small project or prefer not to include external libraries, the built-in `Object.values()` method is a better option. **Library (Underscore.js):** Underscore.js is a popular JavaScript utility library that provides a collection of functional programming helpers. In this case, its `_.values()` function is used as an alternative to the built-in `Object.values()` method. **Special JS feature/syntax: None mentioned in the provided benchmark.** To run these tests, you would need to create a new project on MeasureThat.net and paste the provided JSON code. The website will then execute the benchmarks on various devices and browsers, providing raw data that can be analyzed to compare the performance of both methods. If you're interested in running similar benchmarks or exploring other JavaScript microbenchmarks, I recommend checking out MeasureThat.net's documentation and examples for more information.
Related benchmarks:
lodash.keys vs Object.keys
lodash.keys [4.17.11] vs Object.keys
lodash.values vs Object.values
Lodash values vs Object.values
Native Object.values().some() vs lodash _.some()
Comments
Confirm delete:
Do you really want to delete benchmark?