last Item of array

Benchmark created on


Description

Which is faster

Setup

const array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]

Test runner

Ready to run.

Testing in
TestOps/sec
Get by split
const lastElement = array.slice(-1)[0]
ready
get by array length
const lastElement = array[array.length - 1]
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.