1
- // Object in basically colection of key value pairs
1
+ // Object in basically collection of key value pairs
2
2
let old = {
3
3
"name" : "Swapnil" , // left is key and right one is value
4
4
"rollno" : 76 , // We assign any type to keys
@@ -8,7 +8,7 @@ console.log(old);
8
8
// Output { name: 'Swapnil', rollno: 76 }
9
9
10
10
let a = {
11
- name : "Swapnil" , // We can omit the " " in keys but for string values it is neccessary
11
+ name : "Swapnil" , // We can omit the " " in keys but for string values it is necessary
12
12
rollno : 76 , // We assign any type to keys
13
13
} ;
14
14
@@ -24,22 +24,22 @@ let b = {
24
24
console . log ( b ) ;
25
25
// Output { name: 'Swapnil', rollno: 'Swap' }
26
26
27
- console . log ( a [ "name" ] ) ; // This way we can get a perticular value for a key. " " around are imp.
27
+ console . log ( a [ "name" ] ) ; // This way we can get a particular value for a key. " " around are imp.
28
28
29
- console . log ( a . name ) ; // This way you can get the value of perticular element
29
+ console . log ( a . name ) ; // This way you can get the value of particular element
30
30
// Output Swapnil
31
- a . name = "Swapnil Satish Shinde" ; // This way we can change a perticular property of object
31
+ a . name = "Swapnil Satish Shinde" ; // This way we can change a particular property of object
32
32
33
- console . log ( a . name ) ; // This way you can get the value of perticular element
33
+ console . log ( a . name ) ; // This way you can get the value of particular element
34
34
// Output Swapnil Satish Shinde
35
35
36
36
console . log ( a ) ;
37
37
// Output { name: 'Swapnil Satish Shinde', rollno: 76 }
38
38
39
39
let objectWithFunction = {
40
- name : "Swapnil" , // We can omit the " " in keys but for string values it is neccessary
40
+ name : "Swapnil" , // We can omit the " " in keys but for string values it is necessary
41
41
rollno : 76 , // We assign any type to keys
42
- getfull : function ( ) { // Dont use arrow funciton here as arrow functions dont have this property
42
+ getfull : function ( ) { // Dont use arrow funciton here as arrow functions don't have this property
43
43
console . log ( `${ this . name } ${ this . rollno } ` ) ;
44
44
}
45
45
} ;
0 commit comments