This is an interesting article just because of the image, that is explaining all the methods. Just go through the article once and have a look at the above image. You will definitely have very few to zero doubts left.
Sometimes we need to find things within some conditions. Let us assume that we want to get all the items equal to or less than 100, then all we need to use is the filter method. Here is an example below. This filter method will only return an array of objects where your condition is true.
3. The find method
The find method will help us to find an object within an array. This is also like the previous method. Just replace the map with the find method, then mention the condition that you’re looking for/finding in the array. The function will return only the first match. You can also find someone by age in the below example.
findIndex() method returns the index of the first element in an array that passes a test (provided as a function).
fill() method changes all elements in an array to a static value, from a start index (default
0) to an end index (default
array.length). It returns the modified array.
some() method tests whether at least one element in the array passes the test implemented by the provided function. It returns true if, in the array, it finds an element for which the provided function returns true; otherwise it returns false. It doesn’t modify the array.
every() method tests whether all elements in the array pass the test implemented by the provided function. It returns a Boolean value.
Have a great day!