JavaScript this Keyword Explained In 3 Minutes

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

In this quick tutorial we will look at the "this" keyword in JavaScript. With the addition of new features in JavaScript over the past few years there has been increasing confusion over how "this" actually works. We will cover how "this" works in the global scope, local scope, in Objects, in constructors, and more..
_____________________________________

📚 Learn to CODE in just a FEW months here:
_____________________________________

🛠️ Tools I use:

_____________________________________

💖 Show support!
_____________________________________

Watch Next:
_____________________________________

Connect With Me:
_____________________________________

** Affiliate Disclaimer: Some of the above links may be affiliate links, which may generate me a sales commission at no additional cost to you.

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

Thanks for all of the support!! Hopefully this helps at least 1 person..

Next up Learn Sass in 30 Minutes:

📚 My Favorite Web Design Books 📚
Web Design with HTML, CSS, JavaScript and jQuery Set by Jon Duckett (paid link)

codeSTACKr
Автор

this.partOfJavascript = "Confusing";

everydaydadok
Автор

listPets function can also be resolved using arrow functions with "forEach" loop. ie:

listPets: function () {
this.pets.forEach(element => {
console.log(this.name, element)
});
}

Great content thank you!!

paujoan
Автор

This was surprisingly clear and easy to understand. Thank you!

randomsht
Автор

Wow this video makes it amazingly clear. And trust me, I've had ENOUGH tutorials/lectures on what "this" is

Josh-gecr
Автор

1:32 - Arrow functions always bind to the global object - is this really true? Update: Arrow functions bind either to the parent function, meaning, if the arrow function is inside of a regular parent function, it will take "this" from the parent function or, if it is not inside another function, it will indeed bind to Global.

Elator
Автор

Thank you. Clearly didn't understand

knightrder
Автор

The topic is explained in a very clean way. Thank you!

oxanasf
Автор

Best "this" video i've seen so far. I finally understand it

thomascarlton
Автор

this is just as confusing as anything else in my JavaScript textbook. Awesome.

notconvinced
Автор

This was amazing and really helpful.
Please make a video on javascript data structures and closures

samdimahmood
Автор

Really good work i finally understood it :) :)

tylercode
Автор

first of all thank you for these videos, we'll really appreciate if you can make php course. thank you again for your help

issammbarek
Автор

this is so much easier to understand! you really saved my brain from melting lol

kiattim
Автор

Underated channel by far. Keep up the good work boss. Just a note for that user object example. Another way of achieving the same result would be to make the anonymous function in the forEach an arrow function :
const user = {
firstName: "John",
lastName : "Doe",
pets: ["cat", "dog"],
listPets() {
this.pets.forEach( pet => {
${pet}`)
})
}
}

ThePulseProducer
Автор

That was a very good explanation! Thank you very much!

oliobgmoti-bulgaria
Автор

In the forEach() if we use an arrow function instead of a regular one, why it is correct whithout the extra `this` at the end? Also what scope does the arrow function has at that point?

tzaftanisemmanouhl
Автор

Very Easy to understand thanks for this😎

uprisemotivation
Автор

Quality Content, more explanations please

sohhamm
Автор

wow the best way to explain. thank u so much for unmistify the this

ammarhassan_