Arrays in JavaScript Blog

Arrays in JavaScript

I really enjoyed learning JavaScript for this class. It reminded me of when I learned Java. I especially enjoyed learning about arrays because of how useful they are when paired with loops. With both loops and arrays, JavaScript really shows its potential.

When I was learning Java, my favorite project used arrays, loops, and event handlers to create a cool looking page. On the page I had placed 10 circle objects randomly. Each of these circles was created and placed in a circle array when the window loaded. When your mouse hovered over one of the circles, that circle would change colors and would change back when your cursor moved away. If you clicked on the circle, it would change colors permanently and would create 10 more circles. All the circles were created with the same methods and event handlers. When we finally started using arrays and loops in JavaScript, I felt that same enjoyment and excitement like I did when I started that project.

Arrays and loops are very powerful and useful tools for programming. They make the webpages interactive and store essential data for the user. Loops are great for when you need to use the same code over and over without having to type it out for every possible iteration. For some loops, they can be iterated an infinite number of times. That would be impossible to replicate with branching and nested if statements. Arrays are a great way to store data because an object can hold its own data, methods and even other objects. It keeps everything organized and easy to access.

(☰)