Hey all, in this JavaScript tutorial for beginners, I want to introduce you to the THIS keyword, so… Ninjas, meet the THIS keyword. THIS, meet the ninjas :). Anyway, THIS in JavaScript is a very useful tool, and refers to whatever object currently owns the context you are working in.
For example, at the root of your document, the Window object owns it, so THIS represents the Window object. Therefore, we can call any property on THIS (within the Window context) as we can on the Window object itself.
Any questions, just ask!
SUBSCRIBE TO CHANNEL – https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg?sub_confirmation=1
========== JavaScript for Beginners Playlist ==========
========== CSS for Beginners Playlist ==========
========== HTML for Beginners Playlist ==========
========== The Net Ninja ============
For more front-end development tutorials & to black-belt your coding skills, head over to – https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg or http://thenetninja.co.uk
========== Social Links ==========
Twitter – @TheNetNinja – https://twitter.com/thenetninjauk
Original source
26 responses to “JavaScript Tutorial For Beginners #29 – THIS Keyword”
So basically 'this' depends on 2 factors?
1. If not within an object, it refers to the window.
2. If within an object, refers to the object.
Anything I missed?
One of the best way to explain this.Never seen consoling this before.Great job Shaun.
Thankyou!!
seriously, why can't all tutorials be this simple to understand. Sometimes the way it is explained and the examples used are what makes all the difference in understanding such abstract concepts.
I feel like I found a hidden gem of YouTube discovering your channel! Don't ever stop!
I am taking Udacity's Front End Developer Nanodegree and you just explained the "this" keyword better than their 19 part series in 5 minutes, thank you.
this explanation is easily understandable. thx man keep it up!
Awesome work, keep it up!
Great and clear explanations. Keep up your good work! ?
Thanks for such a straightforward video. They are rare gems to come by. I have a question though. Doesn't the "this" keyword only work when a method is called and not a regular function? That is what I learned, but it seems like you were able to run a regular function and still use "this".
Thanks a lot for what you've been doing, man. I'm terrible at understanding the academic language used in most books on JS, so your straightforward explanations have been of great help for me.
You are the best! I have been looking for this explanation for a really long time, Thanks!
I have read like five different info sources and nothing. But your 5 min video and I understood everything. It's not just about "this" word. It's about the entire JS course. Big thanks for your hard work and keep doing teaching. Its definitely a calling 🙂
so, this -> javascript /and/ self -> python 😉
thanks you
You are totally a piece of awesomeness!!!
Im pretty new to coding and programming but i think its awesome but i didnt quite get the THIS keyword, like what is THIS, is it inside the 1st opening bracket to the 1st ending bracket if u put it inside those brackets?
you are a ninja indeed, i'm impressed with all your tutorials… thanks dude
Awesome, great explanation!
DUDE, you have a gift.. of teaching, I hae been trying to understand the concept of 'this' for days now, and I watch your 5 MIN video and i GOT IT. This is why I love youtube, I am thankful for videos like this and person like you 🙂
Awesome. Thank you!
Nicely explained. Thanks!
Hey i can't get speed value from that code https://jsfiddle.net/y3woue33/ can you help me?
After watching I must say that this is the first time I've truly understood how "this" works in JavaScript.
Thanks, really helpful.
That one is really helpful. Finally I understood !
mmhm