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"
1var person = {
2 first_name : "Marty",
3 last_name : "Mcfly",
4 born : 1968,
5 died : 1933,
6 lovers: ["Jennifer Parker","Baines McFly"]
7};
1let object = {
2 'key1': 'value1',
3 'key2': 'value2',
4 'keyn': 'valuen',
5};
6console.log(object);
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 obj = {
2// fields
3 name:"value",
4 num: 123,
5//methods
6 foo: function(){}
7
8}
1function Dog() {
2 this.name = "Bailey";
3 this.colour = "Golden";
4 this.breed = "Golden Retriever";
5 this.age = 8;
6}