From the course: Learn JavaScript: Write Modern Code with JavaScript ESNext

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Learn about arrays in JavaScript

Learn about arrays in JavaScript

- Now that we've seen how objects work, it's time to take a look at arrays in JavaScript. Now, if you're coming to JavaScript from another language, the language you're coming from probably had a very similar construct, although it may have been called something else, such as a list, or a collection. In JavaScript, arrays are ordered collections of values, usually defined using square brackets like this. The values in an array can be any of the basic data types, and the values that any individual array contains don't all have to be the same data type as some other statically typed languages require. Now, before we go any further, you may have noticed that arrays aren't listed as one of the basic data types in JavaScript, and that's because in JavaScript, arrays aren't technically their own data type, they're actually considered objects, as we can see if we use the type of operator on our array, which looks like this. Now, in the vast majority of situations, this is really more of just…

Contents