JavaScript Array Methods

Some important Array Methods to familiarize yourself with to make life easier as a programmer:

Photo by Isabella and Louisa Fischer on Unsplash
We are going to use this array of items for  all the different array methods
We are going to use this array of items for  all the different array methods
We are going to use this list of items for all the different array methods

Map:

Now, let’s look at the next array method which is going to be map. Map allows us to take one array and convert into a new array, so all the items in the array is going to look slightly different.

Find:

Find method allows us to find a single object in an array.

forEach:

Next we’re going to look at the forEach method which, unlike these other methods does not actually return anything. It is going to work very similarly to a for loop.

Some:

Next, we are going to talk about the some function, which is a bit different than the other ones, since instead of returning a brand new array, it’s going to return true or false so for example we can check if some of the items in the array has a price less than a $100.

Every:

The next array method every is very similar to some except for, instead of checking for one one item, it checks to make sure every single item falls under that condition. So, let’s say we’re checking for less than or equal to $100. This is going to check if every item is less than a $100.

Reduce:

Reduce is a bit different than others, since it actually does some operations on the array and returns a combination of all those different operations. So if we wanted to get the total price of all the items in the array, we will do something like the following example:

Software Engineer | Day Dreamer | Get Better by the Day