JavaScript Find Last

I have been a full-stack developer for twelve years and am currently part of the Cloud FinOps team at Atlassian. I previously ran an App development agency, managing various teams across design and development, leading web, backend and native mobile app developers in Australia and Europe. My strengths are system architecture design and communicating complicated tech to everyday people. Having helped scale tech at numerous startups, I am passionate about making a positive difference. When not working, you can find me writing tech articles and teaching Javascript and React at SheCodes, an initiative helping to get more women into tech. I regularly give talks on various topics, focusing on the impact the technology we build can have. I am devastated by the state of the world, love a good political rant and can often be swearing at no one in particular. I enjoy building things in JavaScript, Deno and Node.
We all have used find before on an array, but what if we wanted to start from the end of the array? Well, thanks to findLast you no longer need to perform some weird logic or use an external library to pull this off.
In this example, you can see how findLast works the same way as find the only difference is that it starts from the end of the array.
const numbers = [5, 10, 15, 20, 25]
// Find starts from the begining
const n = numbers.find(num => num > 10)
console.log(n) // 15
// Find Last starts from the end
const n = numbers.findLast(num => num > 10)
console.log(n) // 25
Other than IE, you can use findLast in all major browsers. Check the browser compatibility list for more info.




