Arrays can contain different data types. This is a fully viable array:
const myArray = ['hello',1,'goodbye',null,true,1,'hello',{ 0 : 1 }]
It contains strings, numbers, Booleans, null, and an object. This is fine! While in practice you may not be mixing data types, there's nothing preventing you from doing so.
There is a quirk about using typeof() on arrays: since they're not true primitives, typeof(myArray) will return object. You should keep that in mind as you write JavaScript.
As we saw before in Chapter 3, Nitty-Gritty Grammar, .push() and .pop() are two of the most useful array methods, to add and remove items from an array, respectively. There are a good number of other methods available, though. Let's take a look at a few.
To create an array, we can do so as in the previous code or simply as const myArray = []. Now, while we can modify the values inside an array, we can declare it as a const because, for most purposes,...