We know an array is a JavaScript object that can hold multiple values under one varaible. This makes grouping in JS loops much easier for us! Think back to the cities example on the previous page as we move ahead in arrays...
CREATING AN ARRAY
Here is the syntax for a literal Array in JavaScript:
var array_name = [ "item1" , "item2" , "item3" , ...] ;
Your Array name will group select items within it, so be mindful when choosing "array_names".
If we use the previous cities example, our literal Array would look something like this:
var cities = [ "NYC" , "Chicago" , "Miami"] ;
Or like this...
var cities = [
"NYC" ,
"Chicago" ,
"Miami"
] ;
Arrays are a JavaScript tool that can be used in several instances to achieve the same goal!
Head back to the HOME page for specific Array examples!