File tree Expand file tree Collapse file tree 2 files changed +75
-0
lines changed Expand file tree Collapse file tree 2 files changed +75
-0
lines changed Original file line number Diff line number Diff line change
1
+ // object is an unordered collection
2
+ // of related date in form of
3
+ // key value pair
4
+
5
+ // const person = {
6
+ // firstName: "Shubham",
7
+ // lastName: "Kadam",
8
+ // age: 23,
9
+ // car: {
10
+ // brand: "Mercedes",
11
+ // year: 2020,
12
+ // },
13
+ // };
14
+
15
+ // console.log(person);
16
+
17
+ // Dot notation
18
+ const person = {
19
+ firstName : "Shubham" ,
20
+ } ;
21
+
22
+ person . dog = {
23
+ name : "fluffy" ,
24
+ age : 2 ,
25
+ } ;
26
+
27
+ person . age = 23 ;
28
+ console . log ( person . dog . age ) ;
29
+
30
+ // Square bracket notation
31
+ const property = "age" ;
32
+
33
+ console . log ( person [ property ] ) ;
Original file line number Diff line number Diff line change
1
+ ## Objects in detail
2
+
3
+ #### Creating an Object
4
+
5
+ ``` js
6
+ // object is an unordered collection
7
+ // of related date in form of
8
+ // key value pair
9
+
10
+ const person = {
11
+ firstName: " Shubham" ,
12
+ lastName: " Kadam" ,
13
+ age: 23 ,
14
+ car: {
15
+ brand: " Mercedes" ,
16
+ year: 2020 ,
17
+ },
18
+ };
19
+ ```
20
+
21
+ #### The Dot and Square Notation
22
+
23
+ ```
24
+ // Dot notation
25
+ const person = {
26
+ firstName: "Shubham",
27
+ };
28
+
29
+ person.dog = {
30
+ name: "fluffy",
31
+ age: 2,
32
+ };
33
+
34
+ person.age = 23; // Age is being added in person object
35
+ console.log(person.dog.age); // 2
36
+
37
+ // Square bracket notation
38
+ const property = "age";
39
+
40
+ console.log(person[property]); // 23
41
+ ```
42
+
You can’t perform that action at this time.
0 commit comments