_.without vs Array.prototype.remove (v2)

Revision 2 of this benchmark created on


Description

Who's faster to delete an element from an array, underscore's without method or implementation of Array remove method ?

Preparation HTML

<script src="//underscorejs.org/underscore-min.js"></script>

Setup

var arr =  _.range(100000);
    var arr2 = _.range(100000);
    var i = 0;
    var j = 0;
    
    Array.prototype.remove = function(from, to) {
      var rest = this.slice((to || from) + 1 || this.length);
      this.length = from < 0 ? this.length + from : from;
      return this.push.apply(this, rest);
    };

Test runner

Ready to run.

Testing in
TestOps/sec
_.without
_.without(arr, i);
++i;
ready
Array.prototype.remove
arr2.remove(j);
++j;
ready

Revisions

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