DEV Community

kapeel kokane
kapeel kokane

Posted on

8 3

8 must-know JavaScript Array Methods in 6 minutes

Hi There!

In today's article, we will cover a few essential JavaScript Array Methods which are absolutely essential in one's journey to becoming an advanced level JS dev. Here goes:

Push | Pop | Shift | Unshift

Well, most of us are aware of the Javascript push() method, but there are also the not so well known pop(), shift(), and unshift() methods as well. Check those out in under a minute:

Reduce

Next up is the reduce method. I have seen several developers abuse logic and invent their own algorithms with new variables in order to accomplish something that could be done with a simple reduce() call. Make sure you know this one:

Includes

Instead of checking for the index of a particular item and checking if it is equal to -1 or not, next time around you could use the inbuilt includes() method that does just the job:

Find

Same is the case with find. Instead of looping over all the array items and then manually comparing each one of them with the one to be found, use the find() method and spend the time saved on that on some video games if you like:

Filter

And lastly the filter function. I have seen code wherein a new empty array is created, and then the main array is looped over and checked for a condition while adding to the new array if the condition satisfies. Trust me, the filter() method is a lifesaver:

And that is all for today's post. If you liked that and are interested in getting updates the day I post them and not in an aggregated post like this, then follow me on Twitter:

Cheers! 🙌🏾

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (1)

Collapse
 
frontendengineer profile image
Let's Code

nice article. i made some videos as well and would like to include it here for more optional references on the topic.



The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay