<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
<script type="text/javascript">
window.lodash = _;
_ = null;
</script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.13.6/underscore-min.js'></script>
<script type="text/javascript">
window.underscore = _;
_ = null;
</script>
var str1 = "abcdefghijklmnopqrstuvwxyz"
var str1copy = "abcdefghijklmnopqrstuvwxyz"
underscore.isEqual(str1, str1copy);
lodash.isEqual(str1, str1copy);
str1 === str1copy
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
Underscore equal(1.13.6) | |
Lodash equal | |
=== |
Test name | Executions per second |
---|---|
Underscore equal(1.13.6) | 8773635.0 Ops/sec |
Lodash equal | 8873468.0 Ops/sec |
=== | 16103987.0 Ops/sec |
Benchmark Overview
MeasureThat.net is a website that allows users to create and run JavaScript microbenchmarks. The provided benchmark compares the performance of three equality checks: ===
(using strict equality), Lodash's isEqual
, and Underscore's isEqual
. We will analyze the options being compared, their pros and cons, and other considerations.
Comparison Options
The benchmark tests three options:
===
): This method checks if two values have the same value and data type.isEqual
: Lodash is a utility library that provides a variety of functions for common tasks, including equality checking. isEqual
takes two arguments: the first value to compare, and the second value to compare with. It returns a boolean indicating whether the values are equal.isEqual
: Underscore is another utility library that provides similar functionality to Lodash. isEqual
works similarly to Lodash's isEqual
, but with some differences in behavior.Pros and Cons
Here are some pros and cons of each option:
===
):isEqual
:isEqual
:isEqual
, with some differences in behavior. Faster than Lodash's isEqual
.Library and Syntax Considerations
The benchmark uses two libraries:
Both libraries require additional code to be loaded and initialized before use.
Other Alternatives
If you want to compare the performance of other equality checks, such as:
==
): This method checks if two values have the same value, but may not consider data types.