HTML Preparation code:
x
 
1
2
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Tests:
  • lodash union

     
    var a = [ 'a', 'b', 'c' ];
    var b = [ 'b', 'd', 'a', 'e', 'f' ];
    var c = _.union(a, b);
  • new Set

     
    var a = [ 'a', 'b', 'c' ];
    var b = [ 'b', 'd', 'a', 'e', 'f' ];
    var c = [...new Set([...a ,...b])];
  • lodash uniq spread

     
    var a = [ 'a', 'b', 'c' ];
    var b = [ 'b', 'd', 'a', 'e', 'f' ];
    var c = _.uniq([...a, ...b]);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    lodash union
    new Set
    lodash uniq spread

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 26 days ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Chrome 134 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
lodash union 7302797.0 Ops/sec
new Set 9213970.0 Ops/sec
lodash uniq spread 12867453.0 Ops/sec