I can feel you. Not really noob friendly but you can do it!
@ganeshchokhare75255 жыл бұрын
first watch this, It will help you kzbin.info/www/bejne/pJCcoIiGZqyEsJI
@justafreak15able4 жыл бұрын
How are you on every single video I watch?
@jagdeesh93384 жыл бұрын
😂😂nice comment
@memeyan98744 жыл бұрын
i think the "this" issue on javascrpt may just a historicol probrem from the source code,on me case,when i learn python code,i never have any kind of probrem like this
@MosheSchnitzler3 жыл бұрын
"This" was the first word I said as a baby. I can't believe that I'm still stuck here...
@daniyahaider64683 жыл бұрын
lol
@sohailaali20813 жыл бұрын
Did figure it out what exactly is it?? Plaeseeeeeee explain me in simple words😭😭
@CapeSkill2 жыл бұрын
@@sohailaali2081 The keyword ''this'' is basically an object that is binded to the function that is being executed.
@sohailaali20812 жыл бұрын
@@CapeSkill yeah thanks but I already had figured it out last month😂😂❤️
@CapeSkill2 жыл бұрын
@@sohailaali2081 It's not really as difficult as people make it seem to be.
@nithin16743 жыл бұрын
"this" ain't stopping me from going forward in my path.
@nyxmediaentertainment87234 жыл бұрын
" 'this' references the object that is executing the current function" ..simple, yet enlightning.. thanx!
@Ethan-hm4qr3 жыл бұрын
Thanks! This saved me from a lot of confusion
@akashkrishna18733 жыл бұрын
Me too commotion solved
@NINJA29A2 жыл бұрын
“this” is a very useful keyword, I didn’t know it until now I wrote 5 lines of code to do its job. instead I could use “this” one keyword, lol.
@mohitrajput60072 жыл бұрын
This simple line explains the entire concept
@crystall_sh Жыл бұрын
It's not that simple you have to know it's properties where to implement it..
@bileljribi69776 жыл бұрын
I rarely make comments on KZbin, I just want say THANK YOU, this is by far the best explanation for the "this" keyword I have found!
@spondoolie6450 Жыл бұрын
this!
@remifassol419811 ай бұрын
I totally second this! New sub here!
@iLoveTurtlesHaha5 жыл бұрын
Honestly, this makes so much sense to me. When people were telling me the 'this' in JavaScript is complicated I was worried that I would struggle to learn it but it makes so much sense if you stick to the rules for methods, functions, and constructor functions.
@prabdeepdhaliwal97253 жыл бұрын
So from my understanding: NOTE: A *method* is a function within an object. A *callback function* is a function passed as an argument/parameter within another function. ============================================================================== 1. The *'this'* keyword *refers to the global object* (window) when using 'this' *within* a *function* Ex. function Hello() { console.log(this)
@DS-rv2fc Жыл бұрын
honestly, just use an arrow function instead of inserting "this"
@burekburczynski9802 Жыл бұрын
@@DS-rv2fc hi, where is the next lecture of 'this' topic? i searched on YT list but I see nothing to be continue of 'this' lecture...
@user-xw3uj8ij6v3 ай бұрын
It's a myth that content creators keep copying. An object does not own a function, it just has a reference to a function no matter where we declare the function inside the object or outside. The "this" binding is due to 'the dot notation' which is described by ECMAScript standard "13.3.2 Property Accessors" "theObject.theProperty". function Hello() { console.log(this) } const obj = { hello : Hello } obj.hello() // this is obj const myHello = obj.hello; myHello() "this" will be undefined if it's 'use strict' or global object depends on host environment (node.js , browser, ect.) example with forEach just special case of no dot notation, arrow functions fix that because that kind of functions use parent environment which was called with dot notation)
@JeremyGalloway5 жыл бұрын
<a href="#" class="seekto" data-time="25">0:25</a> hands down best "this" definiton I've come across. There is an entire "You Don't Know JavaScript" book dedicated to this exact topic, yet the entire book could not explain it as well as you just did in one sentence...
@1998charan5 жыл бұрын
How about the (this & Object prototypes) portion of "You Don't Know Javascript"? Till that part stands Great. What is your opinion?
@Jimmy-vx7mk4 жыл бұрын
@@1998charan dai ala
@1998charan4 жыл бұрын
@@Jimmy-vx7mk you came to see 'this' it seems :) Intha mottaiyan nalla solluvan
@Jimmy-vx7mk4 жыл бұрын
@@1998charan, my dumb ass still can't understand it.
@nyxmediaentertainment87234 жыл бұрын
Yeap! I felt it too! Very well put!
@oloyang431 Жыл бұрын
One thing you forgot to mention is that if you use an arrow function instead regular function when using a forEach() method in your example the keyword "this" actually refers to the object, and not the global window. So basically, "this" acts differently depending on whether you're using a regular function or an arrow function.
@marvinalone Жыл бұрын
because arrow function creates a closure, it's similar to var that = this this.tags.forEach(function(tag) { console.log(that.title, tag) })
@AkashhGuptaa Жыл бұрын
@@marvinalone man your keywords tags that this really confused me
@fleurdecerisier95507 ай бұрын
😢😢
@kduisheev43554 жыл бұрын
still could not manage to explain to my 7 yrs old brother.
@sukhdevduhariya32803 жыл бұрын
hahaha
@mohammaddh86553 жыл бұрын
i don't know about your brother but I'm 24 and I'm fucked
@ayoubZaZen3 жыл бұрын
@@mohammaddh8655 same hhhhhhhhhhhhhhhhhh
@bryanurizar3 жыл бұрын
What a dumbass. A 7 year old struggling to understand this.
@awekeningbro12073 жыл бұрын
i tried to explain this to my 7 year old brother, then i realized i don't have one.
@ganeshbabu64584 жыл бұрын
Without you, I wouldn't have learnt Angular. You're the best lecturer out there Mosh...
@taleoftravels67014 жыл бұрын
Trying to summarize 'this' after watching this video for at least 5th time: For fns inside Objects: 'this' refers to the object calling the function. For fns not called by objects - Eg call back functions - 'this' refers to the global object. For fns defined using arrow functions - 'this' simple refers to the object that is executing the arrow function - Irrespective of object's scope. Meaning: if the arrow function is called from a global scope? 'this' will refer to the global object. If the arrow function is called with in a function which belongs to an object?'this' will refer to the calling function's scope and in this case the object itself.
@dingdong87044 жыл бұрын
you confused about what i had learnt till now, thanks to me for reading your comment.
@nirajankhadka26614 жыл бұрын
Can somebody summarize this comment further for me plss
@theSUBVERSIVE4 жыл бұрын
I think it means that in the last example, if instead of: 1) this.tags.forEach(function (tag) {console.log(this.title, tag}, this) 2) this.tags.forEach((tag)=>{console.log(this.title, tag)} he could get the same result by using an arrow function instead because it would inherit the _this_ from above, calling the Object itself
@thanachon88923 жыл бұрын
"THIS" is all summary that I want for enlightened myself. Thank you!
@omageprosper96732 жыл бұрын
thanks
@katkodes6055 Жыл бұрын
I've been trying to understand this for over 48 hours and I finally get it!! Thanks :)
@alcestabyss3305 Жыл бұрын
Hi, from which sourse are you learning java script? 😊
@katkodes6055 Жыл бұрын
@@alcestabyss3305 mainly the Odin project and published books
@lindag57335 ай бұрын
This might sound over-the-top but I almost feel like crying! I can now understand what my Javascript: The Comprehensive Guide, is talking about!!!! Because of this video, I now understand. I wound not give up. Your video blew the doors open for my understanding. I can literally breathe easier now. I am preparing to freelance! Thank you and God bless you :)
@rodrigoribeiro3774 жыл бұрын
THIS is an incredible explanation... not only about the reserverd word 'this' but also about the behaviour of structures that uses 'this' such as constructor functions. It cleared my mind. Thanks!
@siddharthmagadum163 жыл бұрын
I heard this channel a lot. By watching THIS first video, I got to know THIS is an awesome channel . Crystal clear explanation. Thanks a lot. Subscribed!
@m.smanoj46885 ай бұрын
AWESOMELY EXPLAINED - EVEN PAID COURSES CANNOT COME NO WAY NEAR THIS KIND OF EXPLANATION LIKE THIS
@antonmariadas77473 жыл бұрын
Best explanation ever. Simple, concise and very clear.
@Mattou28125 жыл бұрын
You are a very good teacher. now i understand the basics of this thanks to you. I love your Javascript videos I've learned a lot of things thanks to you. Thanks a lot for sharing your knowledges.
@swethanaik71213 жыл бұрын
"This" is so well explained. Such an eye opener since I have always been confused with the "this" keyword in Javascript since it can mean different things depending on its placement unlike in Java which is pretty straightforward.
@sucesssoulman4 жыл бұрын
Thank you!!!! your explanation is THE BEST!!!!! I understood the concept. There is nothing difficult when someone explains it as clear as possible.
@kunalrajput45394 жыл бұрын
if you use arrow function this will refer to video object not the window object so no need to use forEach
@emmanuelagwu29532 ай бұрын
Thank you so much for this explanation. it makes the concept of the "this" keyword very clear
@MohiyuddinShaikh2 жыл бұрын
This was one of the most beautiful explanation on "this" topic. Heading out to solve some quizzes based on this concept to solidify my learning.
@stephen1569 Жыл бұрын
I loved this video. It untied the “this” knot in my head. MANY THANKS !!!!
@Mu-tp6es5 жыл бұрын
so basically this references the parent of wherever its called unless its called in an ordinary function then it references window
@RickyRicheRebelle5 жыл бұрын
with many MANY exceptions, such as with callbacks, anonymous function expressions, arrow syntax etc etc... still very complicated
@MRAMetharam Жыл бұрын
Have you even noticed that "this" is also different if you build a function using the arrow syntax vs the "function" keyword? Great video BTW.
@degenyakuza Жыл бұрын
this keyword doesn’t work on arrow function
@megl1cious Жыл бұрын
when is in a fat arrow function, this, takes the value of the class where it belongs. In case we haven't given a class it automatically takes class as document class.
@akshaybhatt2136 Жыл бұрын
This is by far the best and the simplest video on 'This'
@kevinmuchene86603 жыл бұрын
Excellent video. By using arrow function ie this.tags.forEach(tag => console.log(this, tag)) works. This is because an arrow function doesn't have its own this value. Instead, it uses this value of the enclosing lexical scope.
@Emre-hr8vf Жыл бұрын
Cleanest "this" explanation in youtube, thanks for sharing.
@sandysandilya3852 Жыл бұрын
Thanks for making it more complicated man
@andrew.schaeffer4032 Жыл бұрын
Bravo. I've watched several videos on the this keyword and this is the best one yet
@vancouverhp902 жыл бұрын
This is the best explain for This keyword i've ever seen :) Thank you so much ....
@guycohen4403 Жыл бұрын
Thank you for the last part with the foreach, I didn't know that callback functions behave like that I didn't know how to fix it until now
@anifsayed35634 жыл бұрын
This is by far the best explanation of this. I was struggling to understand the concept. Thank you very much.
@CheeCarniel11 ай бұрын
The best so far... clearly understood.
@atlasmaxima14186 жыл бұрын
Wow, I watched only the first minute and it makes so much sense now than trying to read articles about it!
@iLoveTurtlesHaha5 жыл бұрын
LMAO, I was trying to read a stupid article as well before leaving it and coming here. XD
@serranomorante5 жыл бұрын
so true.
@cowabungatv41595 жыл бұрын
Indeed the best tutorial on this i've seen so far
@arsheen_coder2503 жыл бұрын
I am trying to write the points he said about this this is helping me to understand try this guys Hope you all understand in sha Allah
@idhamhafidz4 жыл бұрын
I finally understand the part where you add this after callback funtion
@smilejayden-5534 жыл бұрын
Very thanks for a CLEAR explain about 'this'. Love Mosh from Korea
@80Vikram4 жыл бұрын
<a href="#" class="seekto" data-time="440">7:20</a> you've mentioned that's topic for next lecture. Please clarify where can I find "next lecture" ?
@Snoo292933 жыл бұрын
I don't know what exactly he was going to include in that lecture, however, for those curious to find out a way to solve that problem, from what I know, you could simply use arrow function instead of normal function, arrow function treats this differently than normal functions, that's the main reason arrow functions of ES6 are so cool, one advice I have in order to avoid errors in complicated codes is to use classes for object constructors, functions in the global scope and for object.prototype properties and use arrow functions everywhere else.
@Allisondeluca Жыл бұрын
Thanks. Had to watch twice but now I understand.
@BobbyBundlez4 жыл бұрын
ONE MINUTE IN AND HE ALREADY CLEARED UP SO MUCH
@alagappank12422 жыл бұрын
Only video in you tube that clears the "this" keyword concept💥
@the_yugandharr Жыл бұрын
Bro this stuff is insane. You're an amazing teacher. No doubts left. Thanks a lot Mosh!
@shubham-ghosh4 жыл бұрын
hello.. i am from India. thanks for such a great explanation.
@yeeli79895 жыл бұрын
This is complicated
@jsonkody5 жыл бұрын
No it really is not. Learn more basic stuff. Then make some things. Then come back again, you'll see ;)
@Anniek625 жыл бұрын
explained to my 7 year old nephew. he died
@frugglewiggle5 жыл бұрын
nice pun
@sarangcheruvattil57624 жыл бұрын
@@Anniek62 LMFAO :D :D :D
@BobbyBundlez4 жыл бұрын
@@Anniek62 LMFAOOO
@flaviohenrique52942 жыл бұрын
You explain so simples and direct that I couldn't understand why I didn't figured out this before. Thanks man, best didactic ever.
@davidtran13602 жыл бұрын
Great video. I fully undertand "this" now
@aeris-fy6os6 жыл бұрын
Finally! My question has been answered! Thanks Mosh!
@aeris-fy6os6 жыл бұрын
Programming with Mosh Maybe make a video about best practices in writing Javascript code :)
@user-nj4sw9io1h Жыл бұрын
Thanks for this simple and understandable video.
@Joni67sinix3 жыл бұрын
maaann, I can't explain how much you helped me with this video. congrats for your didactics and thanks a lot!!!!
@drakecoleman93643 жыл бұрын
The first part of your video is th goal for every tutorial out there. And when you made those claims in the begining that you would have the best way to explain it and understand, that inherently put a lot of pressure on you from me, since this video was a quick search to go over it for a different bigger part of my learning, and this is something thats been confusing me.. Well, tbh with you. You succeeded. Well Done man. You did amazing explaining it, and I am in your debt.
@deepak85863 жыл бұрын
This is where I actually I learnt about this!!! thank you so much none in my college explained like this about this!
@2010chalupa11 ай бұрын
Great explanation!!! Learning Typescript here and needed a clear explanation like this one!
@PoetNoPoems5 жыл бұрын
Says it’s complicated from poor teaching material then minute one of his explanation and I’ve got it. Top sh#t mate, thanx
@alwyschwuetz Жыл бұрын
I finally understood how this keyword works!
@DavidCarrizoGuitarra2 жыл бұрын
Great tutorial! Maybe an example (in a news agency) const news { title: "A dog run away", subtitle: "The family is worried", toBlog() { console.log(this); }, toTwit(){ console.log(this); } }; The object is the news if you blog it or twit it. I'am a music teacher but I tried to understand and explain 😁
@mikoaj23234 жыл бұрын
Thanks man! I understood after 3 minutes of ur video
@domenicocucinotta27203 жыл бұрын
First Time I really understood the this keyword! Thanks Mosh,you are a 🌟
@priyamganguly3 жыл бұрын
A small, yet complex, topic made easy through this simple video. Thanks!
@denisatanase75484 жыл бұрын
Now I really get it omg...also with the 'new' keyword, many thanks!
@exikoz5 жыл бұрын
I can't express how valuable this was for me. Chrystal clear
@mohdshoaib76229 ай бұрын
best video to understand this keyword.
@_slier2 жыл бұрын
the `forEach` can easily rebind the `this` context behind your back.. we assume `forEach` call the callback as a floating function.. what happen is our assumption is wrong.. maybe `forEach` call the callback using something like `callback.call(somerandomobj)` .. clearly `this` is referring to somerandomobj
@nadhiffuadi2 жыл бұрын
Amazing! Thank you MOSH! and.... may i know where the next lecture is?
@joeyalfaro23233 жыл бұрын
Very simple rule of thumb if that function is part of an object we call that function and method right so if that function is a method in an object this references that object itself otherwise if that function is a regular function which means it's not part of an object this reference is the global object which is the window object in browsers and global in node.
@relaxpinknoise Жыл бұрын
my instructor sucks in class, so thank you for explaining!!!
@naumanraees29323 жыл бұрын
Mr. Mosh you are really great sir, your teaching style, explanation and your knowledge helped me a lot to clear my ideas
@bibekkhatri4 жыл бұрын
Mosh! your explanation is clear and concise.
@mdirshath41742 жыл бұрын
Thanks for the clear explanation. You really explain complex topics easily understandable. Thank you so much!!!
@FarhanAli-hu8ie4 жыл бұрын
Where is the next lecture? I would like to know more about the other solutions that you mentioned at the end of this video.
@shangshi62864 жыл бұрын
I was wondering the same thing I think you have to pay to watch it. but in the future as long as you stick to the rule of thumb and us arrow function whenever you can, you would probably be fine.
@1vigneshram3 жыл бұрын
I really loved it mosh!!! very confused before now got clear understanding of how this works with practical knowledge
@haythamkenway83434 жыл бұрын
This is the best explanation of 'this' keyword. Thanks a lot mosh 🙂
@ore_bear80453 жыл бұрын
superclass, this explanation of this is the best the world has ever seen.
@kushalkumar49704 жыл бұрын
Wow! You just taught me in first 1 min which I needed the most. Thanks a ton!
@itsthomasYT6 жыл бұрын
Mosh, damet garm. Hichwaght fekr nemikardam ke behtarin moalleme donya ye Hamwatan bashe. Merci. Zemanan man ta hala 2 ta az coursato kharidam. I wish you could create a course about JavaScript Debugging for a real world project. There is nothing like this any where on the web.
@smrutikantnayak36523 жыл бұрын
Mosh, literally i was laughing while the console.log logged this keyword inside the call back.... A great 8 and half minutes spent.. Thank you...
@michaelrosenfeld80552 жыл бұрын
Thank you so much for this. One simple sentence and it somewhat clicked for me.
@ShivamSingh-rj5jd4 жыл бұрын
this video is the best video about *this*
@Aarmaxian5 жыл бұрын
Thanks. A very easy to understand and abundantly clear video.
@tyrodev52813 жыл бұрын
Now "this" is what I came for! Thanks Mosh!
@nizamuddinshaikh31855 жыл бұрын
Simple, concise and to the point explanation shown! Thanks for sharing.
@arthurnino934 жыл бұрын
Favorite tutor mentor in programming
@therealorberon6 жыл бұрын
I need to watch and re-watch this a few times. to get and remember it.
@damian13103 жыл бұрын
I learned something new today. I haven't idea that the second param of the forEach function could add the this keyword!
@user-ru1ef5ui1f10 ай бұрын
Thanks for your teaching
@daniillitvinenko4348 Жыл бұрын
THIS IS INSANE. THANK YOU
@zdargahi10 ай бұрын
thanks for great content, to avoid confusion <a href="#" class="seekto" data-time="221">3:41</a> it would be better not to call the constructor function Video to not mix it with object video above.
@a_maxed_out_handle_of_30_chars11 ай бұрын
simple and to the point, thank you ;)
@narekmalkhasyan96364 жыл бұрын
Thank you very much. The easiest explanation for --this-- keyword.
@4aLse2 жыл бұрын
holy macaroni, thanks for the video!! wonderfully explained.
@erin19612 жыл бұрын
Thanks a lot, at least now I know 'this' in forEach(). Hoping to learn more
@EvenAsChrist4 жыл бұрын
Best explanation so far
@cauebahia2 жыл бұрын
Sharp explanation! Thank you
@faisalahmed94344 жыл бұрын
Mosh is always a good teacher!!
@mongstyt99466 ай бұрын
'This' will not stop me from learning Javascript
@dankquan7435 жыл бұрын
Excellent Video Mosh. Can we get one like this on Bind, Call, and Apply?
@katiushka224 жыл бұрын
THIS was driving me crazy until I watched your video. Thanks!!!