Objects and JSON
Objects group related data under named keys:
const book = { title: "Dune", year: 1965, tags: ["sci-fi", "classic"] };
console.log(book.title); // dot access
console.log(book["year"]); // bracket access
console.log(book.tags.length); // 2
JSON is the text format used to send objects over the network. JSON.stringify(obj) converts an object to JSON text and JSON.parse(text) does the reverse.
Try it
Print:
Dune (1965)
Tags: 2
{"title":"Dune","year":1965,"tags":["sci-fi","classic"]}