File tree Expand file tree Collapse file tree 1 file changed +4
-16
lines changed Expand file tree Collapse file tree 1 file changed +4
-16
lines changed Original file line number Diff line number Diff line change @@ -12,25 +12,13 @@ const drink = {
12
12
id : 'XAT5621' ,
13
13
name : 'Root Beer' ,
14
14
price : 99 ,
15
- getDrinkDetails ( ) {
16
- return `Drink ${ this . name } (${ this . price } )`
17
- }
18
- } ;
19
-
20
- // PREVIOUS METHOD (babel)
21
- const oldDrink = {
22
- id : 'XAT5621' ,
23
- name : 'Root Beer' ,
24
- price : 99 ,
25
- getDrinkDetails : function ( ) {
26
- return `Drink ${ this . name } (${ this . price } )`
27
- }
15
+ getDrinkDetails : ( ) => `Drink ${ this . name } (${ this . price } )` ,
28
16
} ;
29
17
30
18
console . log ( drink . getDrinkDetails ( ) ) ;
31
- console . log ( oldDrink . getDrinkDetails ( ) ) ;
32
19
33
20
/**
34
- * Two objects are never the same {} === {} is false
35
- * Unless you are comparing a byRef like drink === drinkReference
21
+ * Using arrow functions breaks thge use of this
22
+ * because in the arrowe function 'this' is determined by
23
+ * ther calling method
36
24
*/
You can’t perform that action at this time.
0 commit comments