_.without vs Array.prototype.remove
JavaScript performance comparison
Info
Who's faster to delete an element from an array, underscore's without method or implementation of Array remove method ?
Preparation code
<script src="//underscorejs.org/underscore-min.js"></script>
<script>
Benchmark.prototype.setup = function() {
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);
};
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
_.without |
|
pending… |
Array.prototype.remove |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published
- Revision 2: published
0 comments