Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Comparing performance of: array length = 0 vs array = [] vs arra.splice(0)
(version: 1)
Comparing performance of:
array length = 0 vs array = [] vs array.splice(0)
Created:
6 months ago
by:
Guest
Jump to the latest result
Script Preparation code:
var arr = [1,2,3,4];
Tests:
array length = 0
arr.length = 0
array = []
arr = []
array.splice(0)
arr.splice(0)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
array length = 0
array = []
array.splice(0)
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
6 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Browser/OS:
Chrome 142 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
array length = 0
33980488.0 Ops/sec
array = []
9685842.0 Ops/sec
array.splice(0)
52274420.0 Ops/sec
Related benchmarks:
Array Splice vs Splice
`Array.slice(-1)[0]` vs `Array[Array.length]`
`Array.slice(-1)[0]` vs `Array[Array.length]` for 10000 length
Array: slice vs splice
array.splice vs array.length
slice vs length-1
empty an array in JavaScript - splice vs setting length faster
Array.splice(0, N) vs Array.length === N
array.length = 0 vs []
Comments
Confirm delete:
Do you really want to delete benchmark?