Test name | Executions per second |
---|---|
set | 6824063.0 Ops/sec |
uniq | 7982080.5 Ops/sec |
<script src='https://cdn.jsdelivr.net/npm/lodash@4.17.10/lodash.min.js'></script>
var arr = [5,1,3,7,9,2,11];
var mySet = new Set(arr);
mySet.add(12);
mySet.add(12);
mySet.add(5);
mySet.add(17);
mySet.add(1);
mySet.add(11);
return arr;
arr = _.uniq(arr.push(12));
arr = _.uniq(arr.push(12));
arr = _.uniq(arr.push(5));
arr = _.uniq(arr.push(17));
arr = _.uniq(arr.push(1));
arr = _.uniq(arr.push(12));
return arr;