JavaScript arrays are a fundamental part of the language, and mastering the array functions it offers is essential for any senior developer. These ...
Some comments have been hidden by the post's author - find out more
For further actions, you may consider blocking this person and/or reporting abuse
Nice article Dipak,
For those wanting to know more on this topic, I recommend visiting the authoritative web site: MDN JavaScript Array.
I think it is also worth noting that some developers will highlight the fact that methods such as
forEach
perform worse than a regularfor
loop. However, I would argue:I would go further to suggest that the declarative style of
forEach
andmap
etc. is easier to read and comprehend, but that might just be me.On the performance issue, one should ask the question "How performant does it need to be?" The usual answer for frontend is "fast enough so the user is not waiting and wondering if the browser has crashed". If the functionality really needs to be in the browser there are other options than using JS in the main thread such as Web Workers or even Web Assembly. On the backend there is no real reason (if performance really is paramount) to be using JS, there are plenty of other options.
Regards.
These should know every junior
Really, senior developers should know these? I think every developer should know some of them, others shouldn't be used since they mutate the array and we should instead use toSlice, toSort, etc which don't mutate the array.
sigh, just reiterating a well-known topic?
thanks for the explaination, but i still confuse about splice(),
const numbers = [1, 2, 3, 4, 5];
numbers.splice(2, 1, 99);
console.log(numbers); // [1, 2, 99, 4, 5]
in splice parameter, it say '2' for index 2 which means refer to '3', and '99' parameter is refer to what number will be changed to. but '1' in parameter means to what? can someone explain me
btw, sorry for my bad english
Thank you for your question! @richantfebriel
The second parameter in
splice()
specifies the number of elements to remove starting at the index given by the first parameter. For example:Here,
1
means remove one element (which is3
). If you change1
to2
:This removes two elements (
3
and4
), and then inserts99
.I hope this clears up the confusion!
thanks for the explanation, easy to understand!
your welcome
Calling it array methods would be okay
Eh... So... In short: every developer should read the javascript documentation for Array and Hash... Surprising! What an article!
Thanks @petrfischer
Nice refresher! Sometimes I forget some of these exist. Also, for...of is useful as well.
Thanks for the list - certainly some things for me to try here!
thanks for the share. this list will help me immensely!
Thank for sharing
As a junior dev, I appreciate the curated list for refreshment purposes. A bit easier of a read than MDN docs.
Thanks @dmiller72
Great, But these are the basic functions. This should be only for junior devs. Those who are senior devs already know all of the functions.
Reach++
Appreciate your effort, but it is not specific to Seniors, every junior devs (should) knows this too. Also, there are several articles about array methods already in dev.to
Thanks for sharing
Fantastic
Very informative.
Thanks for Sharing 🤝🏻
Useful
That's helpful thanks🙏
Don't forget sort()
Cool!
nice article!
Magnifico, conciso y preciso, una guia de consulta rapida.Mil gracias PURA VIDA
Thank you so much! I'm really glad you found it helpful. Pura vida!
Hi Dipak Ahirav,
Top, very nice and helpful !
Thanks for sharing.
对于我这样的初学者来说,这也是有必要掌握的