Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Browser:
Chrome 121
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
Just instantiate new array
99.1M/s
Set length to zero
18.2M/s
View exact numbers
Test name
Executions per second
✓
Just instantiate new array
99,094,184 Ops/sec
Set length to zero
18,150,330 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)