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
Go 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
arr[arr.length - 1]
849.8M/s
arr.slice(-1)[0]
41.3M/s
View exact numbers
Test name
Executions per second
✓
arr[arr.length - 1]
849,750,784 Ops/sec
arr.slice(-1)[0]
41,266,820 Ops/sec
Related benchmarks
slice vs length-1
Comments
Confirm delete:
Do you really want to delete benchmark?