From the course: JavaScript Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Arrays in code

Arrays in code

- [Instructor] An array is an instance of the array object and we declare a new array by creating a variable then using square brackets to wrap around a comma separated list of each of the items within that array. So each of these items take up a slot in the array. If we console.log out an array in the browser, you can see here we have an array with four items and we got a list of all four of those items and you clearly see that we can mix different data types with the same array, so we have a string, we have a variable that pulls in the string, and we have a number and we then have a boolean value. Also notice at the bottom we have a property in the array, and it's the length property that gives us the total length of the array. So if I instead go here and say collection.length then we just get the number signifying how long that array is and how many items are in the array. To access a specific item within an array,…

Contents