Arrays
Explore JavaScript arrays to understand how they store data, how to access items using zero-based indexes, and how to add or remove elements using methods like push, pop, shift, and unshift. Discover the difference between copying arrays by reference and by value through array destructuring. This lesson builds foundational skills for handling arrays effectively in your Meteor.js and React applications.
We'll cover the following...
What’s an array?
An array is a data structure in JavaScript that’s similar to a list used for storing shopping items. The list of items in an array is enclosed in a square bracket ([]).
The shopping list above can be represented in code below:
let shoppinglist = ["bananas", "milk", "cereals", "sugar", "eggs"];
We can access items on an array by using the index of the item. An array has a length property that defines the length of the array (the number of items present inside it). ...