Homelab, Linux & ABAP (~˘▾˘)~
 

[JavaScript] Get the Last Item in an Array

const animals = [‘cat’, ‘dog’, ‘horse’]

// before
const lastItem = animals[animals.length - 1]

// ES2022
const lastItem = animals.at(-1)

Leave a Reply

Your email address will not be published.