lukedavies.dev

Search by title or category tag

New Array methods in es2023

Luke Davies

TILjs

12/05/2023

I get pretty excited when we’re given new methods to work with and theres a few handy new array functions released in the latest es2023 proposals I’d like to talk about here. Firstly

findLast()

You can check MDN and see that findLast() is compatible across all browsers.

.findLast() MDN compatibility chart
.findLast() MDN compatibility chart

If you’re using the find method, each item is iterated over till the condition is met. Take this example:

const numbers = [42, 57, 1, 55, 86];

console.log("find:");

const findResult = numbers.find((value)=>{
  console.log('checking', value);
  return value === 86
});