Cut end of array

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var testArray = [1,2,3,4,5,6,7,8,9,10];
    var i;
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Splice negative
testArray.splice(-2);
for (i=0;i<testArray.length;i++) {

}
pending…
Splice exact
testArray.splice(8, 10);
for (i=0; i<testArray.length;i++) {

}
 
pending…
-2
for (i=0; i<(testArray.length - 2);i++) {

}
pending…
Slice with dec
var newArray = testArray.slice(0, 8);
for (i=0; i<newArray.length;i++) {

}
pending…
Slice without dec
for (i=0; i<testArray.slice(0, 8).length; i++) {

}
pending…
Change length
testArray.length = 8;
for (i=0; i<testArray.length; i++) {

}
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

Add a comment