JavaScript Problem: Searching an Array for a Value

Searching an array is a common task. In the past we have relied on indexOf and lastIndexOf. As of ES6 there are two new array methods: findIndex and find. This tutorial covers indexOf, lastIndexOf, findIndex and find.

Would you like to help keep this channel going?

For a complete list of all our tutorials:

Take the Learn Modern JavaScript: Getting Started or the Learn Modern JavaScript: Advanced Topics courses at a huge discount:

To view a tutorial on the ES5 Array methods:

8 Comments on “JavaScript Problem: Searching an Array for a Value”

  1. Good one!
    But if i may ask, what about forEach method?
    It can also be used to find a certain value inside of an array. Right?
    It will go through each element inside of an array and return the value that we need.

  2. Concise and to the point! Do you have a video on comparison of two arrays, finding duplicates, removing them and concatenating them? I am trying to loop over a array that splices itself (poping off duplicate value), obviously this doesnt work. Is it okay to mutate a array or create a new array due to "immutability programming styles"

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.