DEV Community


Posted on


An Introduction to Helpful Array Methods

I'm not an expert on coding by any means, in fact, I'm currently enrolled in a full-stack development course which I am only in the middle of. That being said, there were a few useful things I learned about arrays and how to deal with the data stored inside of them. However, this post is just about array methods. The first thing i learned about array methods is that the methods will loop through the array for you, searching for data based on the method you used. This means we don't need to use 'for' loops to loop through the entire array, the methods will do it for us.

The first one is the forEach() array method. This method goes through the entire array and basically grabs each element on the array and then you can perform different actions with that data.

The next one is the filter() method. This one allows us to filter data out from the array based on the specifications we give it.

Another useful method is the includes() method. This loops through the array and finds any element with the parameters you specify, similar to the filter() method.

There is push() which allows you to add new elements to the end of an array. This can be useful for making lists of any kind.

Finally, splice() is a very useful method because it allows to either "splice" and element into the array, or add it, but it can also delete items or "splice" them out in the same fashion.

These are just a few of the different types of array methods out there, but these are a few I found particularity helpful!

Top comments (0)

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git