Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
empty an array in JavaScript and then reassign again
Based on question on http://stackoverflow.com/questions/1232040/how-do-i-empty-an-array-in-javascript
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 Edg/121.0.0.0
Browser:
Chrome 121
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Just instantiate new array
165872608.0 Ops/sec
Set length to zero
19034412.0 Ops/sec
Tests:
Just instantiate new array
let arr1 = ["a", "b", "c", "d", "e", "f"]; arr1 = [1,2,3,4,5];
Set length to zero
const arr2 = ["a", "b", "c", "d", "e", "f"]; arr2.length = 0; arr2.push(1,2,3,4,5)