Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
Chrome 73
Mac OS X 10.14.3
Desktop
6 years ago
Test name Executions per second
_.uniq 4126639.0 Ops/sec
set 2299983.0 Ops/sec
uniq by filter 5934721.5 Ops/sec
HTML Preparation code:
AخA
 
1
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script>
Script Preparation code:
 
var elements = [1,2,3,1,2,4,2,3,5,3]
Tests:
  • _.uniq

     
    _.uniq(elements)
  • set

     
    [...new Set(elements)]
  • uniq by filter

     
    elements.filter((v, i, a) => a.indexOf(v) === i)