DEV Community

Victor Hazbun
Victor Hazbun

Posted on

Daily tasks with JavaScript arrays

Arrays are everywhere and we have to use them all the time.

I created this article specially for you, so you have a quick reference of the most common things you usually do with Arrays on a daily basis 😊

Table Of Contents 📋

Find in array 🔍

Filter an array 🕵️

Loop arrays 🔁

Sort an array of objects ⬆️ ⬇️

Add an element to an array 🗳️

Remove an element from an array 🗑️

Create an array from an existing array (Map) 📦

Accumulate array values (Reduce) 🐝

Combine arrays (Concat) 🍔

Hope you enjoyed this reading 🥳. Feel free to save this article into your bookmarks 🔖 so you have it available at your fingertips.

Top comments (11)

Collapse
 
dennisk profile image
Dennis Keirsgieter •

In Sort array of objects usersSortedByScoreDesc still returns asc i believe?

But great reference all together!

Collapse
 
victorhazbun profile image
Victor Hazbun •

Fixed! Thanks again!

Collapse
 
dennisk profile image
Dennis Keirsgieter •

Did you also include the fix? The result is still the same for me even after a hard refresh!

Thread Thread
 
victorhazbun profile image
Victor Hazbun •

Please refresh again.

Thread Thread
 
victorhazbun profile image
Victor Hazbun •

Worked for you now?

Thread Thread
 
dennisk profile image
Dennis Keirsgieter •

Yes it works now! Altough the json.stringify was actually nice to make it more readable :)

Thread Thread
 
victorhazbun profile image
Victor Hazbun •

I used it for debugging purposes, but now you give me a good idea 😁 - I will put it back everywhere later.

Collapse
 
victorhazbun profile image
Victor Hazbun •

There is another interesting blog I published yesterday 👉 dev.to/victorhazbun/modern-javascr...

Collapse
 
zafer profile image
Zafer •

Broken chrome tab after too many embed code editor :) It would be better if it had been placed less opts.

Collapse
 
victorhazbun profile image
Victor Hazbun • • Edited

I will try to split my blog posts, i.e. Part 1, Part 2, etc. Since the embed code editor gives the reader the ability to play with the code. 😅

Collapse
 
victorhazbun profile image
Victor Hazbun •

You bet, I will continue adding more of this for you.