Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36 Edg/90.0.818.51
Chrome 90
Mac OS X 10.15.7
Desktop
3 years ago
Test name Executions per second
lodash union 2041470.9 Ops/sec
object.assign 567195.5 Ops/sec
lodash uniq spread 3161430.8 Ops/sec
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);
  • object.assign

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

     
    var a = [ 'a', 'b', 'c' ];
    var b = [ 'b', 'd', 'a', 'e', 'f' ];
    var c = _.uniq([...a, ...b]);