Комментарии:
I finally know why we need to bind(this) for class components... because otherwise "this" is global context rather than parent context - thank you sir!
Ответитьit's very hard to do a video like this, thank you. I think functions should be explained in hoisting as they can be invoked before declaring, I know it's one of those js quirks
Ответитьthanks
Ответитьthanks!
Ответитьyou missed the return keyword in function
ОтветитьYou have an error explaining the difference between arrow and plain function:
First of all, you used classes, which is really bad for explaining diff between arrow vs regular functions.
If I add following code to jsfiddle/codesandbox I am getting compiler errors => we should use only methods inside classes.
But anyway your getSurname method returns nothing, so undefined is the only value you could get.
If you return this you would get object here, this is some weird behavior of classes which is not obvious again.
And generally, after your example, it seems like we need to use arrowFunctions for object methods, when the reality is opposite:
We need to use arrow functions almost everywhere where we want to save current context e.g. callbacks, but for object methods, where we need to use regular functions.
Excellent video! That channel worth more boost! Keep going well man!
Ответитьthanks
ОтветитьThanks.
ОтветитьRegarding class example and „this” binding. You are not returning anything from getSurname function. That is why I think you are getting undefined. If you console log “this” for both functions you should get class context.
ОтветитьYou explained Closures with one more js topic I was asked in an interview "Currying". I guess this is a bonus hidden tip for this video. 😛
ОтветитьExcellent content as always🔥🔥🔥
Ответить