DEV Community

tashigyatso45
tashigyatso45

Posted on

Array Methods

 Recently, I have been learning about Arrays and I found it really interesting and useful. Today I am going to share some of the things I learned about Array's on this platform, hoping it can help other programmers new to the journey! 
 Lets define Arrays first; Arrays are "Objects" that are listed and in order. Why are they important? They can be useful when we want to store data in an organized fashion. For example if wanted to store a data of a list of number from lowest to highest we would use an Array.
How can we interact with Arrays using Array methods? There are many different Array methods we can use to interact with Arrays. For example if we wanted to remove the last index from an Array consisting of [1,2,3,4,5], we can use the .pop() method. If we wanted to remove the first index we can use the .shift() method. There are also methods to add indexes to an Array such as .push() and .unshift().
However say we want to make changes to the Array but we want to also keep the Array without it affecting the original Array itself. There's a method to that as well and that is called "spread operator". In JavaScript "spread operator" is represented by 3 periods (...) This allows us to make a copy of the original Array and make changes to the new Array with the same data without affecting the original Array. This method when used in conjunction with the other methods such as .shift() and .pop() becomes a handy tool when dealing with Arrays. 
These are some of the key methods I learned about recently that I felt might be useful for other beginner programmers so I decided to share it on this platform. Thanks for reading and happy coding!
Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
ranggakd profile image
Retiago Drago

It would be nice if you could present them in a pretty way with a basic blogging like these links below:

Collapse
 
tashigyatso45 profile image
tashigyatso45

Thank you so much for the feedback!