Function can't make changes in the object?? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

Function can't make changes in the object??

I wrote the following code in which ad() changes the value of tyer in the given obj. But the value is always returned nan and the object remains the same. https://code.sololearn.com/Wxa8Nx4W0gu5/?ref=app

28th Aug 2020, 5:31 AM
Deven
Deven - avatar
2 Réponses
+ 1
Use function instead of an arrow function. An arrow function is not bind to this (I can't explain clearly because I'm new to JS, sorry 🙄). ad : function() { // your code }
28th Aug 2020, 6:51 AM
Théophile
Théophile - avatar
+ 1
That finally worked😲😄😄 thanks a lot. I'am really intrigued to know the reason behind this.
28th Aug 2020, 7:38 AM
Deven
Deven - avatar