Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
empty arrays
(version: 0)
Based on question on http://stackoverflow.com/questions/1232040/how-do-i-empty-an-array-in-javascript
Comparing performance of:
Just instantiate new array vs Set length to zero vs Splice vs Pop all values
Created:
4 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var size = 10000; var arr = []; for (var i = 0; i < size; i++){ arr.push(i); }
Tests:
Just instantiate new array
arr = [];
Set length to zero
arr.length = 0;
Splice
arr.splice(0, arr.length);
Pop all values
while(arr.length) { arr.pop(); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Just instantiate new array
Set length to zero
Splice
Pop all values
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
empty an array in JavaScript?
empty an array in JavaScript?(Yorkie)
empty an array in JavaScript?(Yorkie)1
empty an array in JavaScript - splice vs setting length 2
empty an array in JavaScript - splice vs setting length. 444
Comments
Confirm delete:
Do you really want to delete benchmark?