Non-tech founder’s guide to choosing the right software development partner Download Ebook
Home>Blog>How to get last array element in javascript

How to get last array element in javascript

TIL (Today I Learned) that in JavaScript, there's a cool way to grab the last element of an array using the  at method. Instead of the traditional

const lastMember = members[members.length - 1]
which can sometimes feel clunky, now I can simply use

const lastMember = members.at(-1)
It's a nifty trick that makes code cleaner and more concise. Gotta love those little efficiency boosts in programming!

Discover More Reads

Recent Projects

We take pride in creating applications that drive growth and evolution, from niche startups to international companies.

Let’s Build Something Great Together

Let’s discuss your project and see how Ruby on Rails can be your competitive advantage.

*By submitting this form, you agree with JetRockets’ Privacy Policy