Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
array speed 2
(version: 1)
Comparing performance of:
array[array.length - 1] vs array.slice(-1)[0] vs [...array].reverse()
Created:
10 months ago
by:
Guest
Jump to the latest result
HTML Preparation code:
[...array].reverse()
Script Preparation code:
/*your preparation JavaScript code goes here To execute async code during the script preparation, wrap it as function globalMeasureThatScriptPrepareFunction, example:*/ var array = {a:[0,1,2,3,4]}
Tests:
array[array.length - 1]
/*When writing async/deferred tests, use `deferred.resolve()` to mark test as done*/ array.a[array.a.length - 1]
array.slice(-1)[0]
array.a.slice(-1)[0]
[...array].reverse()
[...array.a].reverse()
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
array[array.length - 1]
array.slice(-1)[0]
[...array].reverse()
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
10 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Browser/OS:
Chrome 137 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
array[array.length - 1]
122332688.0 Ops/sec
array.slice(-1)[0]
42704656.0 Ops/sec
[...array].reverse()
35111464.0 Ops/sec
Related benchmarks:
reate array by lenght
Test array ops
forEach vs for of (with Iterator) 2
Array.from length vs Array
(Fixed) Array.from length vs Array
(Small Array.from length vs Array
Array allocate
Array.from length vs for loop
array last item speed
Comments
Confirm delete:
Do you really want to delete benchmark?