Get Programming with JavaScript - Listing 3.08

Listing 3.08 - Using dot notation to access property values

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

Further Adventures

Listing 3.08 - Using dot notation to access property values - Task 1

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

Listing 3.08 - Using dot notation to access property values - Task 2

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

Listing 3.08 - Using dot notation to access property values - Task 3

var book; var book2; book = { title : "The Hobbit", author : "J. R. R. Tolkien", published : 1937 }; book2 = { title : "Northern Lights", author : "Philip Pullman", published : 1995 }; console.log(book.title); console.log(book.author); console.log(book.published); console.log(book2.title); // log the book's console.log(book2.author); // details to the console.log(book2.published); // console