This is an example of code, from a book called JavaScript: The Definitive Guide, 6th Edition, that I do not understand.
He is talking about Objects.
var book ={
topic: "javascript",
fat: true
};
book.topic => "javascript"
book.["fat"] => True
book.author="flanagan"; // creates new property
book.contents= {}; // empty object*
So what I don't understand is the last part. Is he adding in a new property called "contents" that is empty? Because he is calling it an object and it's confusing me.
contentsand is assigning it a new Object with no properties.book.["fat"]will give youSyntaxError. Use either dot or square brackets but not both of them simultaneously.