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"
1let object = {
2 'key1': 'value1',
3 'key2': 'value2',
4 'keyn': 'valuen',
5};
6console.log(object);
1let obj = {
2// fields
3 name:"value",
4 num: 123,
5//methods
6 foo: function(){}
7
8}
1let myDog = {
2 legs: value
3
4}
5 console.log(myDog);
6/*Doesn't have to be a Dog it can be anyting you want*/
1class ObjectLayout {
2 constructor() {
3 this.firstName = "Larry"; //property
4 }
5
6 sayHi() { // Method
7 return `Hello from ${this.firstName}`;
8 }
9}
10
11const object = new ObjectLayout();
12// object.firstName is Larry;
13// object.sayHi() gives "Hello from Larry"