1var person = {
2 first_name : "Marty",
3 last_name : "Mcfly",
4 born : 1968,
5 died : 1933,
6 lovers: ["Jennifer Parker","Baines McFly"]
7};
1let car = {
2 name: "BMW",
3 colour: "black",
4 year: "2020",
5 owner: {
6 names = ["Andy" , "Steve" , "Tony" ]
7 }
8};
1person = {
2 'name':'john smith'
3 'age':41
4};
5
6console.log(person);
7//this will return [object Object]
8//use
9console.log(JSON.stringify(person));
10//instead
1var obj = {my:"sql", nice:[69, 420]};
2
3obj.my //returns the string "sql"
4obj.nice //returns the array [69, 420]
1// To make an object literal:
2const dog = {
3 name: "Rusty",
4 breed: "unknown",
5 isAlive: false,
6 age: 7
7}
8// All keys will be turned into strings!
9
10// To retrieve a value:
11dog.age; //7
12dog["age"]; //7
13
14//updating values
15dog.breed = "mutt";
16dog["age"] = 8;