Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
arr.slice(-1)[0] vs arr[arr.length - 1]
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:123.0) Gecko/20100101 Firefox/123.0
Browser:
Firefox 123
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
2 years ago
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
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];