findLast & findLastIndex in JavaScript
From the JavaScript Array Methods cheat sheet · Modern Array Methods (ES2023+) · verified Jul 2026
findLast & findLastIndex
Search from the end — perfect for "most recent matching"
javascript
const events = [
{ type: 'login', at: 1 },
{ type: 'click', at: 2 },
{ type: 'login', at: 3 },
{ type: 'logout', at: 4 },
]
const lastLogin = events.findLast(e => e.type === 'login')
// { type: 'login', at: 3 }
const lastLoginIdx = events.findLastIndex(e => e.type === 'login')
// 2💡 Iterates from the end — early-returns on first match like find()
⚡ Way cheaper than `[...arr].reverse().find(...)` on large arrays
📌 findLastIndex returns -1 on no match — same convention as findIndex
🎯 Pair with `with()` for "update the most recent matching item"
es2023search