remove-item-from-array-splice-vs-lodash-without

JavaScript performance comparison

Test case created by doa

Preparation code

<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.8.0/lodash.min.js"></script>

    

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
lodash
members = _.without(members, username);
pending…
splice
for (var i = 0, l = members.length; i < l; i++) {
  if (members[i] === username) {
    members.splice(i, 1);
    return;
  }
}
pending…
for loop
var newMembers = [];

for (var i = 0, l = members.length; i < l; i++) {
  if (members[i] !== username) {
    newMembers.push(members[i]);
  }
}

members = newMembers;
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

0 Comments