This will get the very first element of the ages array as soon as it finds any number that is above 18. Let’s say I want to find the first element which is over 18 in the ages array. The parameter age will have an element from an array on each iteration.įinally, add the condition inside the arrow function We need to pass an arrow function as an argument with the parameter called age to the find() method const ages = To capture each element on each iteration Find() Method In Actionįirst, invoke the find() method in the ages javascript array. Including the second element that meets the condition.
Until the condition we specify is met or satisfied. The find() method will search the very first element from a given javascript array It’s one of the higher order functions similar to map, reduce, filter etc.Īny function that accepts or return another function called higher-order functions.Īpparently find() will only take a function as an argument which is required. The find() method can only be invoked on a Javascript array. Find A Specific Array Index Using findIndex().