ES6 and Typescript Tutorial - 11 - lexical 'this'

preview_player
Показать описание

📱 Follow Codevolution

ES6 | ES2015 | Typescript | ES6 Tutorial | ES2015 Tutorial | Typescript Tutorial | ES6 Tutorial for Beginners | ES2015 Tutorial for Beginners | Typescript tutorial for Beginners
Рекомендации по теме
Комментарии
Автор

arrow function - this : refers to parent's (aka object's)
normal function - this: refers to that function's scope
- so use arrow function, if using 'this'

vigneshgvs
Автор

Wow! your explanation of 'this' is spot on. Didn't know that arrow functions do not create execution context. Thanks

victorchris
Автор

Vishwas, seriously you are awesome, I had watched lot of videos about this keyword, none of them were as clear as this one

saikiran-ttww
Автор

Today I got good explanation regarding "this" keyword, so simple anyone can understand easily. Thanks alot.

prabhatkumar
Автор

Wow your explanation is awesome....please please could you make a series on javascript ...🙏

suchismitamohapatra
Автор

Nice video! It has helped me a lot, but, tere is something that still isn't clear for me:

*function(){*
*this;* //here, this 'this' points to outside of the function, to window.
*}*

*setTimeout(function(){console.log(this)}, 1000);* // so why this function creates its own context for 'this' and that 'this' points to its function context but in the other function mentioned that 'this' points to outside?

Thanks!

Nezahual
Автор

Hi vishwas, thank you for the tutorial. I have a doubt. When I convert greet function to arrow function and use an arrow function inside setTimeout as well, I'm not able to access Id.
let employee = {
Id:1,
greet = () =>{
setTimeout (() => console.log(this.id), 1000)
}
}
employee. greet() ;

Can you please explain why
I'm getting 'undefined' in console

bhavyaramaiah
Автор

hi, in your previous video u said that try to avoid var keyword as much as possible and use let keyword instead of that.but why you use here for object declaration, is there any reason ?

vigneshtamizh
Автор

It took to me sometime to understand 'this' video xD

VishalJangid
Автор

this video: the use of 'self' for the nested 'this'. But with the arrow function, we do not need SELF.

toannew