remove array element

Benchmark created by remove array elment on


Setup

Array.prototype.removeSplice = function(v) {
      var i;
      if (i = this.indexOf(v) > -1) return this.splice(i, 1);
    };
    
    Array.prototype.remove = function(e) {
        var t, _ref;
        if ((t = this.indexOf(e)) > -1) {
            return ([].splice.apply(this, [t, t - t + 1].concat(_ref = [])), _ref);
        }
    };
    
    var arr = [1,2,3];

Test runner

Ready to run.

Testing in
TestOps/sec
splice literal
arr.remove(2)
ready
.splice()
arr.removeSplice(2)
ready

Revisions

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

  • Revision 1: published by remove array elment on