DEV Community

Victor Hazbun
Victor Hazbun

Posted on

30 10

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.

Sentry image

See why 4M developers consider Sentry, β€œnot bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay