DEV Community

Javascript Array Methods. All you really need to know.

Walter Miani on April 25, 2022

The idea of this post is to show you the minimum set of methods you need to deal with to get away with any array-related problems you might encoun...
Collapse
 
mikedepetris profile image
Mike De Petris

ehm... the last part is in Italian ^_^

Collapse
 
walterego profile image
Walter Miani • Edited

Haha very nice. I must have published the wrong draft. Gonna correct it immediately.

Collapse
 
walterego profile image
Walter Miani

Done, thank you @mikedepetris . Pizza time now!

Collapse
 
mikedepetris profile image
Mike De Petris

"If find it very handy" --> "I find it very handy"
anyway pizza is always the answer.

Collapse
 
mikedepetris profile image
Mike De Petris

This is great and usefult writing Walter, thank you.

Collapse
 
rickdelpo1 profile image
Rick Delpo

Thanks for all the detail Walter. Was wondering if people use Lodash these days as a more intuitive way of understanding how reduce works. I had a use case for Lodash and wrote an AWS Lambda function with CRUD against an AWS S3 json file store.

Collapse
 
walterego profile image
Walter Miani

I use Lodash quite a lot, especially for the uniqBy and groupBy array methods. And also for its debounce and throttle. I actually wanted to write a paragraph for lodash in this post but in the end I decided against.

Collapse
 
rickdelpo1 profile image
Rick Delpo

Thanks, this is good to know because I do not write this kind of code too often. I still have trouble fully understanding the Reduce syntax because perhaps I am not that good at JS anyway. I am an SQL developer. Lodash seemed more user friendly.

Collapse
 
yaalfred profile image
Arturas-Alfredas Lapinskas

concat() method is missed

Collapse
 
walterego profile image
Walter Miani

concat is missing because I never use it. The point was to show what I personally use the most.

Collapse
 
walterego profile image
Walter Miani

I'd rather do as: var array3 = [...array1, ...array2] instead of using concat. I'm just more used to the '...' operator since it's also useful with objects.

Collapse
 
jonrandy profile image
Jon Randy 🎖️

reduce is the king of all of these. Super useful for many things

Collapse
 
walterego profile image
Walter Miani

It is very powerful... It isn't just that easy to bear in mind its syntax at the beginning... but when you get it, it's so cool put it in your code :)