The Simplest Explanation of This in JavaScript

preview_player
Показать описание
In today's video we'll explore the simplicity of the "this" keyword in JavaScript, which is one of the most disliked features of the language. I think it's rather simple to understand with the help of logging.

For your reference, check this out:

If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!

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

*LEARN MORE ABOUT THE BIND FUNCTION* 👇

*ENROL IN THE ULTIMATE JAVASCRIPT DOM CRASH COURSE* 👇

dcode-software
Автор

thanks a lot cleared all my confusions in just 4 mins. I have gone though 15 video on YouTube but you are the person who clear the confusion. thank you so much one again.

ibtisamwarraich
Автор

Nice one Dom. Another way to explain "this" is to say it always refers to its direct (first) parent object.
So inside any object this refers to the object. In JS classes (just synthetic sugar for an object) this refers to the instance of the class like in other languages like PHP.
Bind() is a rather queer operator where you can select ANY object to act as this.
Do remember that static values and functions of an object do not have this. You have to refer these by their object / class name.

montebont
Автор

awesome content. really appreciate you for making confusing concept into simpler and easy to understand concept.

sejalsankhe
Автор

brief and great at the same time. you helped a lot

sajjadalvandkoohi
Автор

Easy, clear and very useful content. thank you.

gutsnxr
Автор

what is the keyboard shortcut to move out of bracket pairs?

aayushkunwar
Автор

Didn't understand the last example, why did the arrow function changed this to the Window object? How exactly did that happen? Not clear at all...

techtupi
Автор

I get why some of the comments are...Positive.
I also greatly appreciate what you do...YET you "explained" jack and s h * t...
You just recapped what would naturally be deduced by encountering these scenarios...Not the "WHY" (i.e. the rules that govern them).

I believe in you, do better.

TheOrgCaptainHowdy
Автор

You missed one. Inside an object, 'this' refers to the object itself.

castletown