Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
arr.slice(-1)[0] vs arr[arr.length - 1]
(version: 0)
Comparing performance of:
arr.slice(-1)[0] vs arr[arr.length - 1]
Created:
5 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var arr = Array(100000).fill(1);
Tests:
arr.slice(-1)[0]
arr.slice(-1)[0];
arr[arr.length - 1]
arr[arr.length - 1];
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
arr.slice(-1)[0]
arr[arr.length - 1]
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:123.0) Gecko/20100101 Firefox/123.0
Browser/OS:
Firefox 123 on Mac OS X 10.15
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
arr.slice(-1)[0]
41266820.0 Ops/sec
arr[arr.length - 1]
849750784.0 Ops/sec
Related benchmarks:
`Array.slice(-1)[0]` vs `Array[Array.length]`
`Array.slice(-1)[0]` vs `Array[Array.length]` for 10000 length
slice vs length-1
arr.at(-1) vs arr[arr.length - 1]
Comments
Confirm delete:
Do you really want to delete benchmark?