- deep-equal (v1.1.1 and v2.2.3) with
strict: true - fast-deep-equal (v3.1.1 and v3.1.3)
- lodash.isEqual
- fast-deep-equal - Consistently fastest across all test cases
- lodash.isEqual - Moderate performance, typically 20-50% of fast-deep-equal's speed
- deep-equal - Dramatically slower, especially v2.2.3
| Test Case | fast-deep-equal | lodash.isEqual | deep-equal v1.1.1 | deep-equal v2.2.3 |
|---|---|---|---|---|
| Simple objects | 4.2M ops/sec | 1.1M ops/sec | 238K ops/sec | 9K ops/sec |
| Nested objects | 2.1M ops/sec | 500K ops/sec | 33K ops/sec | 1.2K ops/sec |
| Arrays | 6.2M ops/sec | 2.9M ops/sec | 188K ops/sec | 8K ops/sec |
| Large objects (1000 props) | 5.3K ops/sec | 1.4K ops/sec | 77 ops/sec | 3 ops/sec |
| 16.78MB JSON file | 13ms | 48ms | 983ms | 25,030ms |
Testing [] vs {} and [1] vs {"0": 1}:
| Library | Result | Correct? |
|---|---|---|
| deep-equal v1.1.1 | true |
❌ |
| deep-equal v2.2.3 | false |
✓ |
| fast-deep-equal | false |
✓ |
| lodash.isEqual | false |
✓ |
- v1.1.1: Fast but incorrect (treats arrays and objects as equal)
- v2.2.3: Correct but 25-1000x slower
- The performance regression appears to be the cost of fixing correctness issues
- No significant performance or behavioral differences
- Both versions maintain excellent performance
For a 16.78MB JSON file comparison:
- fast-deep-equal: ~13-24ms (practical for real-time operations)
- lodash.isEqual: ~47ms (acceptable for most use cases)
- deep-equal v1.1.1: ~983ms (noticeable delay)
- deep-equal v2.2.3: ~25 seconds (unusable for large data)
-
Use fast-deep-equal for:
- High-performance applications
- Large data structures
- Frequent equality checks
- Real-time systems
-
Use lodash.isEqual for:
- Applications already using lodash
- When moderate performance is acceptable
- Better ecosystem integration
-
Avoid deep-equal with strict mode for:
- Large objects or arrays
- Performance-critical applications
- Any production use with v2.2.3
- All benchmarks compared two distinct objects (created via separate
JSON.parse()calls) - The performance differences represent actual deep comparison work, not reference checks
- fast-deep-equal has one edge case where it returns
truefor arrays compared to objects with Array constructor - All libraries correctly identify most array vs object comparisons as
false
fast-deep-equal is the clear winner for deep equality checking in JavaScript, offering:
- 10-1000x better performance than alternatives
- Correct behavior in almost all cases
- Consistent performance across versions
- Practical performance even for very large objects