Тёмный

What is THIS in JavaScript? 👈 

Bro Code
Подписаться 1,9 млн
Просмотров 14 тыс.
50% 1

#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",
sayHello: function(){console.log(`Hi! I am ${this.favFood}`)},
eat: function(){console.log(`${this.name} is eating ${this.favFood}`)}
}
const person2 = {
name: "Patrick",
favFood: "pizza",
sayHello: function(){console.log(`Hi! I am ${this.favFood}`)},
eat: function(){console.log(`${this.name} is eating ${this.favFood}`)}
}
person1.eat();
person2.eat();

Опубликовано:

 

14 ноя 2023

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 15   
@BroCodez
@BroCodez 8 месяцев назад
// 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: function(){console.log(`${this.name} is eating ${this.favFood}`)} } const person2 = { name: "Patrick", favFood: "pizza", sayHello: function(){console.log(`Hi! I am ${this.favFood}`)}, eat: function(){console.log(`${this.name} is eating ${this.favFood}`)} } person1.eat(); person2.eat();
@Devanshugoel
@Devanshugoel 4 месяца назад
was struggling with THIS keyword you cleared it in just 5 min dude you are one of the best teacher on youtube
@helioobianchi
@helioobianchi 3 месяца назад
I've seen people saying it's pretty easy to get confused with which object 'this' is referring to. I haven't learned enough to know good JS practices, but it's good to keep it in mind so I know I need to learn this at some point
@sunkorg
@sunkorg 7 месяцев назад
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!
@als4515
@als4515 6 месяцев назад
Hands down, best programming instructor on RU-vid. Simple and clean explanations.
@orderla8877
@orderla8877 4 месяца назад
Bro just "de-obfuscated" my mind. Appreciated and subscribed.
@crazysoul5497
@crazysoul5497 7 месяцев назад
Actually, I was searching for this content. It's really helped me. Thank you so much❤
@joeviloria3409
@joeviloria3409 2 месяца назад
Your videos are amazing! To the point, clear, well illustrated. It has helped me grasp a few concepts better.
@hunin27
@hunin27 7 месяцев назад
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 ❤
@mohammed_mishal
@mohammed_mishal 8 месяцев назад
will you be my mentor :), on my way to learn full stact(MERN) development.
@nemesisxl6736
@nemesisxl6736 7 месяцев назад
We need more React content :((
@helioobianchi
@helioobianchi 3 месяца назад
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'?
@mehnajiktafena
@mehnajiktafena 8 месяцев назад
Thank you guys❤
@NazneenNaharNishi
@NazneenNaharNishi 7 месяцев назад
My Bro, why you are not making android development tutorial???????????☺☺☺☺☺☺☺☺☺
@idontknowwhattonamethischa4592
@idontknowwhattonamethischa4592 7 месяцев назад
I liked my own comment
Далее
JavaScript CONSTRUCTORS in 5 minutes! 🛠
5:32
Просмотров 21 тыс.
What are JavaScript PROMISES? 🤞
12:37
Просмотров 42 тыс.
3M❤️ #thankyou #shorts
00:16
Просмотров 6 млн
▼ЧЁРНАЯ МАГИЯ 🔮
31:15
Просмотров 453 тыс.
JavaScript FUNCTIONS are easy! 📞
12:14
Просмотров 24 тыс.
STOP Using Classes In JavaScript | Prime Reacts
14:02
Просмотров 224 тыс.
The JavaScript SUPER keyword is super! 🦸‍♂️
9:22
JavaScript DESTRUCTURING in 8 minutes! 💥
8:41
Просмотров 13 тыс.
Learn JavaScript CLOSURES in 10 minutes! 🔒
10:58
Просмотров 13 тыс.
Learn JSON in 10 Minutes
12:00
Просмотров 3,1 млн
JavaScript this Keyword Explained Simply
11:42
Просмотров 13 тыс.
Every React Concept Explained in 12 Minutes
11:53
Просмотров 429 тыс.
JavaScript GETTERS & SETTERS are awesome!!! 📐
13:14
3M❤️ #thankyou #shorts
00:16
Просмотров 6 млн