What is THIS in JavaScript? 👈

preview_player
Показать описание
#JavaScript #tutorial #course

// this = reference to the object where THIS is used
// (the object depends on the immediate context)

const person1 = {
name: "Spongebob",
favFood: "hamburgers",
}
const person2 = {
name: "Patrick",
favFood: "pizza",
}

Рекомендации по теме
Комментарии
Автор

// this = reference to the object where THIS is used
// (the object depends on the immediate context)

const person1 = {
name: "Spongebob",
favFood: "hamburgers",
sayHello: function(){console.log(`Hi! I am ${this.favFood}`)},
eat: is eating ${this.favFood}`)}
}
const person2 = {
name: "Patrick",
favFood: "pizza",
sayHello: function(){console.log(`Hi! I am ${this.favFood}`)},
eat: is eating ${this.favFood}`)}
}

person1.eat();
person2.eat();

BroCodez
Автор

was struggling with THIS keyword you cleared it in just 5 min dude you are one of the best teacher on youtube

Devanshugoel
Автор

Hands down, best programming instructor on YouTube. Simple and clean explanations.

als
Автор

This is great! Can you explain in more detail in a later video on why arrow functions don't recognize "this?" I understand it has to do with scope, but I'm not quite wrapping my head around how arrow functions handle scope differently. Thanks again for your time and expertise sharing this!

sunkorg
Автор

I was struggling with the 'this' keyword a bit as a novice programmer, but this video made it clear as day. Thank you so much!

nickyrenz
Автор

Bro just "de-obfuscated" my mind.
Appreciated and subscribed.

orderla
Автор

The "Hi, I am hamburgers" 😂

pam
Автор

Actually, I was searching for this content. It's really helped me.
Thank you so much❤

crazysoul
Автор

God bless you and the day you decided that you wanted to open a YouTube channel man

EliasVargas-ve
Автор

<*_> This is my seal. I have watched the entire video, understood it, and I can explain it in my own words, thus I have gained knowledge. This is my seal. <_*>

piotrmazgaj
Автор

Your videos are amazing! To the point, clear, well illustrated. It has helped me grasp a few concepts better.

joeviloria
Автор

since it is the same as writing the name of the object, is this keyword used in case there are nameless things? or so that you can use the same code for different objects since it automatically updates the object name in the method? Thanks so much bro, even if you don't answer, I know you've got work to do ❤

hunin
Автор

will you be my mentor :), on my way to learn full stact(MERN) development.

mohammed_mishal
Автор

My Bro, why you are not making android development

NazneenNaharNishi
Автор

I still feel confused with those different ways of writing functions. What are the differences between them? why doesn't the arrow function refer to the object in which it was written when using 'this'?

helioobianchi
welcome to shbcf.ru