3 Things that Helped Me Understand Arrays

Brian Nelson
Brian Nelson
Published in
2 min readDec 18, 2020

Arrays were really complicated for me to learn, these are some things that helped me learn as a noob.

Arrays can get overwhelming

Arrays are more complex data than just normal variables, because of this it was difficult for me to sort out the nuances of them. I’m still learning how to work with arrays in a professional way and these are things that have helped me through some struggle to figure these out.

Print array data in its most basic form to the console.

This helped me get a picture of what I was working with and was especially helpful when pulling information from something like an API. You can see in in the console how many layers you're working with by looking for the the square brackets [] for arrays and curly brackets {} for objects. Arrays and objects often go together especially in API’s as far as I've found.

Learn how to use the “for in loop” and the “for of loop”

Learning how to use these two above mentioned loops really helped me to be able to extract information from arrays and use it (especially for Vue.js as far as I know). For in loops are generally used to loop through objects with properties (usually enclosed with curly braces). For of loops are generally used for looping through arrays. Learning the combination of these and testing them out on a small scale helped me start to understand this basic concept of javascript. I also recommend this video by Zac Gordon as one of the best explanations of the mater.

Adding and Subtracting items from arrays

In my opinion “splice()” and “push()” are the most important methods you can learn to manipulate arrays, reading about them on MDN and testing them on a small scale using JSfiddle. Learning about these and trusting that they work the way they say they do is imperative to understanding the ins and outs of storing information in arrays.

Conclusion

Arrays can be hard to wrap your head around, especially if your new to coding. I found that constantly checking documentation, looking for simple concise explanations and simply trying things on a small scale can help you better understand arrays if they are tricky for you like they were for me.

Brian Nelson is a student in the Digital Media program at Utah Valley University, Orem Utah, studying Web & App Development. The following article relates to a project that involved creating a battleship program with arrays in the DGM 1600 Course and representative of the skills learned.

--

--