1var obj = {
2 prop1: 5,
3 obj2: {
4 prop1: [3, 6, 3],
5 prop2: 74,
6 prop3: {
7 str: "Hello World"
8 }
9 }
10};
11
12console.log(obj.obj2.prop3.str); //output: "Hello World"
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
1let computer = {
2
3 CPU: "Intel i9",
4 motherboard: "MSI MPG Z490",
5 graphicsCard: "NVIDIA 3090",
6 powerSupply: "Redragon RGPS GC-PS003",
7 getSpecs: function() {
8
9 return "My computer is equipped with a(n) " + this.CPU + ", a(n) " + this.motherboard + " motherboard, a(n) " + this.graphicsCard + " GPU and a(n) " + this.powerSupply + " power supply.";
10
11 }
12
13};
14
15console.log(computer.getSpecs());
16
17// OUTPUT: My computer is equipped with a(n) Intel i9, a(n) MSI MPG Z490 motherboard, a(n) NVIDIA 3090 GPU and a(n) Redragon RGPS GC-PS003 power supply.