Get Programming with JavaScript - Listing 8.02

Listing 8.02 - Using existing objects in an array

var place1 = { name : "The Pyramids", country : "Egypt" }; var place2 = { name : "The Grand Canyon", country : "USA" }; var place3 = { name : "Bondi Beach", country : "Australia" }; var thisYear = [ place1, place2 ]; var nextYear = [ place3 ]; console.log(thisYear); console.log(nextYear);

Further Adventures

Listing 8.02 - Using existing objects in an array - Task 1

var place1 = { name : "The Pyramids", country : "Egypt" }; var place2 = { name : "The Grand Canyon", country : "USA" }; var place3 = { name : "Bondi Beach", country : "Australia" }; var thisYear = [ place1, place2 ]; var nextYear = [ place3, place1 ]; console.log(thisYear); console.log(nextYear);

Objects can be assigned to multiple variables and arrays.