Get Programming with JavaScript - Listing 3.03

Listing 3.03 - A book as an object

var book; book = { title : "The Hobbit", author : "J. R. R. Tolkien", published : 1937 }; console.log(book);

Further Adventures

Listing 3.03 - A book as an object - Task 1

var book; book = { title : "The Hobbit, or There and Back Again", // update title author : "J. R. R. Tolkien", published : 1937 }; console.log(book);

Listing 3.03 - A book as an object - Task 2

var book; var book2; // declare a new variable book = { title : "The Hobbit, or There and Back Again", author : "J. R. R. Tolkien", published : 1937 }; // assign a new book to the variable book2 = { title : "Northern Lights", author : "Philip Pullman", published : 1995 }; console.log(book);

Listing 3.03 - A book as an object - Task 3

var book; var book2; book = { title : "The Hobbit, or There and Back Again", author : "J. R. R. Tolkien", published : 1937 }; book2 = { title : "Northern Lights", author : "Philip Pullman", published : 1995 }; console.log(book); console.log(book2); // log the new book