Test name | Executions per second |
---|---|
Native | 1.5 Ops/sec |
Lodash | 1.8 Ops/sec |
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js"></script>
const limit = 10000000;
var array = [];
for (let i = 0; i < limit; i++) {
array.push(i);
}
function getRandomIndex() {
return Math.floor(Math.random() * array.length)
}
var element = array[getRandomIndex()];
array.filter(x => x === element);
_.remove(array, x => x === element);