JavaScript this Keyword

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ก.พ. 2025

ความคิดเห็น • 547

  • @nithin1674
    @nithin1674 4 ปีที่แล้ว +90

    "this" ain't stopping me from going forward in my path.

  • @nyxmediaentertainment8723
    @nyxmediaentertainment8723 4 ปีที่แล้ว +201

    " 'this' references the object that is executing the current function" ..simple, yet enlightning.. thanx!

    • @Ethan-hm4qr
      @Ethan-hm4qr 3 ปีที่แล้ว +6

      Thanks! This saved me from a lot of confusion

    • @akashkrishna1873
      @akashkrishna1873 3 ปีที่แล้ว

      Me too commotion solved

    • @TheCashFlowHQ
      @TheCashFlowHQ 3 ปีที่แล้ว +2

      “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.

    • @mohitrajput6007
      @mohitrajput6007 3 ปีที่แล้ว +3

      This simple line explains the entire concept

    • @crystall_sh
      @crystall_sh 2 ปีที่แล้ว +2

      It's not that simple you have to know it's properties where to implement it..

  • @MosheSchnitzler
    @MosheSchnitzler 3 ปีที่แล้ว +137

    "This" was the first word I said as a baby. I can't believe that I'm still stuck here...

    • @daniyahaider6468
      @daniyahaider6468 3 ปีที่แล้ว

      lol

    • @sohailaali2081
      @sohailaali2081 3 ปีที่แล้ว

      Did figure it out what exactly is it?? Plaeseeeeeee explain me in simple words😭😭

    • @CapeSkill
      @CapeSkill 3 ปีที่แล้ว +2

      @@sohailaali2081 The keyword ''this'' is basically an object that is binded to the function that is being executed.

    • @sohailaali2081
      @sohailaali2081 3 ปีที่แล้ว

      @@CapeSkill yeah thanks but I already had figured it out last month😂😂❤️

    • @CapeSkill
      @CapeSkill 3 ปีที่แล้ว +1

      @@sohailaali2081 It's not really as difficult as people make it seem to be.

  • @iLoveTurtlesHaha
    @iLoveTurtlesHaha 6 ปีที่แล้ว +15

    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.

  • @MsElsospechoso28
    @MsElsospechoso28 5 ปีที่แล้ว +816

    THIS is where I quit programming.

    • @ecosunflower1892
      @ecosunflower1892 5 ปีที่แล้ว +23

      I can feel you. Not really noob friendly but you can do it!

    • @ganeshchokhare7525
      @ganeshchokhare7525 5 ปีที่แล้ว +5

      first watch this, It will help you th-cam.com/video/n_9oUP1GQz0/w-d-xo.html

    • @justafreak15able
      @justafreak15able 5 ปีที่แล้ว +14

      How are you on every single video I watch?

    • @jagdeesh9338
      @jagdeesh9338 5 ปีที่แล้ว +4

      😂😂nice comment

    • @memeyan9874
      @memeyan9874 5 ปีที่แล้ว +1

      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

  • @bileljribi6977
    @bileljribi6977 6 ปีที่แล้ว +108

    I rarely make comments on TH-cam, I just want say THANK YOU, this is by far the best explanation for the "this" keyword I have found!

  • @JeremyGalloway
    @JeremyGalloway 5 ปีที่แล้ว +47

    0:25 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...

    • @1998charan
      @1998charan 5 ปีที่แล้ว

      How about the (this & Object prototypes) portion of "You Don't Know Javascript"?
      Till that part stands Great. What is your opinion?

    • @Jimmy-vx7mk
      @Jimmy-vx7mk 5 ปีที่แล้ว

      @@1998charan dai ala

    • @1998charan
      @1998charan 5 ปีที่แล้ว

      @@Jimmy-vx7mk you came to see 'this' it seems :)
      Intha mottaiyan nalla solluvan

    • @Jimmy-vx7mk
      @Jimmy-vx7mk 5 ปีที่แล้ว

      @@1998charan, my dumb ass still can't understand it.

    • @nyxmediaentertainment8723
      @nyxmediaentertainment8723 4 ปีที่แล้ว

      Yeap! I felt it too! Very well put!

  • @ganeshbabu6458
    @ganeshbabu6458 4 ปีที่แล้ว +11

    Without you, I wouldn't have learnt Angular. You're the best lecturer out there Mosh...

  • @prabdeepdhaliwal9725
    @prabdeepdhaliwal9725 4 ปีที่แล้ว +22

    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
      @DS-rv2fc ปีที่แล้ว +2

      honestly, just use an arrow function instead of inserting "this"

    • @burekburczynski9802
      @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...

    • @Rinat-p7f
      @Rinat-p7f 9 หลายเดือนก่อน +2

      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)

  • @lindag5733
    @lindag5733 10 หลายเดือนก่อน +2

    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 :)

  • @taleoftravels6701
    @taleoftravels6701 5 ปีที่แล้ว +105

    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.

    • @dingdong8704
      @dingdong8704 4 ปีที่แล้ว +8

      you confused about what i had learnt till now, thanks to me for reading your comment.

    • @Sinner_17
      @Sinner_17 4 ปีที่แล้ว +4

      Can somebody summarize this comment further for me plss

    • @theSUBVERSIVE
      @theSUBVERSIVE 4 ปีที่แล้ว +7

      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

    • @thanachon8892
      @thanachon8892 3 ปีที่แล้ว +3

      "THIS" is all summary that I want for enlightened myself. Thank you!

    • @omageprosper9673
      @omageprosper9673 3 ปีที่แล้ว

      thanks

  • @swethanaik7121
    @swethanaik7121 3 ปีที่แล้ว +9

    "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.

  • @rodrigoribeiro377
    @rodrigoribeiro377 5 ปีที่แล้ว +4

    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!

  • @oloyang431
    @oloyang431 ปีที่แล้ว +17

    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
      @marvinalone ปีที่แล้ว

      because arrow function creates a closure, it's similar to
      var that = this
      this.tags.forEach(function(tag) {
      console.log(that.title, tag)
      })

    • @Akash_Unreal
      @Akash_Unreal ปีที่แล้ว +1

      @@marvinalone man your keywords tags that this really confused me

    • @fleurdecerisier9550
      @fleurdecerisier9550 ปีที่แล้ว

      😢😢

  • @siddharthmagadum16
    @siddharthmagadum16 4 ปีที่แล้ว +2

    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!

  • @kduisheev4355
    @kduisheev4355 4 ปีที่แล้ว +210

    still could not manage to explain to my 7 yrs old brother.

    • @sukhdevduhariya3280
      @sukhdevduhariya3280 4 ปีที่แล้ว

      hahaha

    • @mohammaddh8655
      @mohammaddh8655 4 ปีที่แล้ว +12

      i don't know about your brother but I'm 24 and I'm fucked

    • @ayoubZaZen
      @ayoubZaZen 4 ปีที่แล้ว +1

      @@mohammaddh8655 same hhhhhhhhhhhhhhhhhh

    • @bryanurizar
      @bryanurizar 4 ปีที่แล้ว

      What a dumbass. A 7 year old struggling to understand this.

    • @awekeningbro1207
      @awekeningbro1207 3 ปีที่แล้ว +13

      i tried to explain this to my 7 year old brother, then i realized i don't have one.

  • @m.smanoj4688
    @m.smanoj4688 10 หลายเดือนก่อน

    AWESOMELY EXPLAINED - EVEN PAID COURSES CANNOT COME NO WAY NEAR THIS KIND OF EXPLANATION LIKE THIS

  • @katkodes6055
    @katkodes6055 2 ปีที่แล้ว +1

    I've been trying to understand this for over 48 hours and I finally get it!! Thanks :)

    • @alcestabyss3305
      @alcestabyss3305 2 ปีที่แล้ว +1

      Hi, from which sourse are you learning java script? 😊

    • @katkodes6055
      @katkodes6055 2 ปีที่แล้ว +1

      @@alcestabyss3305 mainly the Odin project and published books

  • @antonmariadas7747
    @antonmariadas7747 4 ปีที่แล้ว +7

    Best explanation ever. Simple, concise and very clear.

  • @Mattou2812
    @Mattou2812 6 ปีที่แล้ว +7

    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.

  • @Mu-tp6es
    @Mu-tp6es 5 ปีที่แล้ว +10

    so basically this references the parent of wherever its called unless its called in an ordinary function then it references window

    • @RickyRicheRebelle
      @RickyRicheRebelle 5 ปีที่แล้ว +2

      with many MANY exceptions, such as with callbacks, anonymous function expressions, arrow syntax etc etc... still very complicated

  • @akshaybhatt2136
    @akshaybhatt2136 2 ปีที่แล้ว

    This is by far the best and the simplest video on 'This'

  • @MRAMetharam
    @MRAMetharam 2 ปีที่แล้ว +3

    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.

    • @ethisfreedom
      @ethisfreedom 2 ปีที่แล้ว

      this keyword doesn’t work on arrow function

    • @megl1cious
      @megl1cious 2 ปีที่แล้ว

      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.

  • @MohiyuddinShaikh
    @MohiyuddinShaikh 2 ปีที่แล้ว +2

    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.

  • @BobbyBundlez
    @BobbyBundlez 5 ปีที่แล้ว +2

    ONE MINUTE IN AND HE ALREADY CLEARED UP SO MUCH

  • @sucesssoulman
    @sucesssoulman 4 ปีที่แล้ว +2

    Thank you!!!! your explanation is THE BEST!!!!! I understood the concept. There is nothing difficult when someone explains it as clear as possible.

  • @kevinmuchene8660
    @kevinmuchene8660 3 ปีที่แล้ว +2

    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.

  • @atlasmaxima1418
    @atlasmaxima1418 6 ปีที่แล้ว +3

    Wow, I watched only the first minute and it makes so much sense now than trying to read articles about it!

    • @iLoveTurtlesHaha
      @iLoveTurtlesHaha 6 ปีที่แล้ว

      LMAO, I was trying to read a stupid article as well before leaving it and coming here. XD

    • @serranomorante
      @serranomorante 6 ปีที่แล้ว

      so true.

  • @andrew.schaeffer4032
    @andrew.schaeffer4032 2 ปีที่แล้ว

    Bravo. I've watched several videos on the this keyword and this is the best one yet

  • @CheeCarniel
    @CheeCarniel ปีที่แล้ว

    The best so far... clearly understood.

  • @arsheen_coder250
    @arsheen_coder250 3 ปีที่แล้ว

    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

  • @stephen1569
    @stephen1569 2 ปีที่แล้ว

    I loved this video. It untied the “this” knot in my head. MANY THANKS !!!!

  • @aemre.a
    @aemre.a 2 ปีที่แล้ว

    Cleanest "this" explanation in youtube, thanks for sharing.

  • @alagappank1242
    @alagappank1242 3 ปีที่แล้ว

    Only video in you tube that clears the "this" keyword concept💥

  • @anifsayed3563
    @anifsayed3563 4 ปีที่แล้ว +2

    This is by far the best explanation of this. I was struggling to understand the concept. Thank you very much.

  • @drakecoleman9364
    @drakecoleman9364 4 ปีที่แล้ว

    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.

  • @guycohen4403
    @guycohen4403 2 ปีที่แล้ว

    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

  • @flaviohenrique5294
    @flaviohenrique5294 3 ปีที่แล้ว

    You explain so simples and direct that I couldn't understand why I didn't figured out this before. Thanks man, best didactic ever.

  • @PoetNoPoems
    @PoetNoPoems 5 ปีที่แล้ว +1

    Says it’s complicated from poor teaching material then minute one of his explanation and I’ve got it. Top sh#t mate, thanx

  • @the_yugandharr
    @the_yugandharr 2 ปีที่แล้ว

    Bro this stuff is insane. You're an amazing teacher. No doubts left. Thanks a lot Mosh!

  • @idhamhafidz
    @idhamhafidz 5 ปีที่แล้ว +3

    I finally understand the part where you add this after callback funtion

  • @emmanuelagwu2953
    @emmanuelagwu2953 7 หลายเดือนก่อน

    Thank you so much for this explanation. it makes the concept of the "this" keyword very clear

  • @sandysandilya3852
    @sandysandilya3852 ปีที่แล้ว +1

    Thanks for making it more complicated man

  • @smrutikantnayak3652
    @smrutikantnayak3652 3 ปีที่แล้ว

    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...

  • @exikoz
    @exikoz 5 ปีที่แล้ว +4

    I can't express how valuable this was for me. Chrystal clear

  • @Joni67sinix
    @Joni67sinix 4 ปีที่แล้ว

    maaann, I can't explain how much you helped me with this video. congrats for your didactics and thanks a lot!!!!

  • @smilejayden-553
    @smilejayden-553 4 ปีที่แล้ว

    Very thanks for a CLEAR explain about 'this'. Love Mosh from Korea

  • @DavidCarrizoGuitarra
    @DavidCarrizoGuitarra 2 ปีที่แล้ว

    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 😁

  • @cowabungatv4159
    @cowabungatv4159 5 ปีที่แล้ว +2

    Indeed the best tutorial on this i've seen so far

  • @vancouverhp90
    @vancouverhp90 3 ปีที่แล้ว

    This is the best explain for This keyword i've ever seen :) Thank you so much ....

  • @ankjumper
    @ankjumper 4 หลายเดือนก่อน +3

    even with your brilliant teaching and demonstration, its just so confusing.

  • @aeris-fy6os
    @aeris-fy6os 6 ปีที่แล้ว +11

    Finally! My question has been answered! Thanks Mosh!

    • @aeris-fy6os
      @aeris-fy6os 6 ปีที่แล้ว

      Programming with Mosh Maybe make a video about best practices in writing Javascript code :)

  • @kunalrajput4539
    @kunalrajput4539 4 ปีที่แล้ว +1

    if you use arrow function this will refer to video object not the window object so no need to use forEach

  • @deepak8586
    @deepak8586 3 ปีที่แล้ว

    This is where I actually I learnt about this!!! thank you so much none in my college explained like this about this!

  • @joeyalfaro2323
    @joeyalfaro2323 3 ปีที่แล้ว

    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.

  • @2010chalupa
    @2010chalupa ปีที่แล้ว

    Great explanation!!! Learning Typescript here and needed a clear explanation like this one!

  • @shubham-ghosh
    @shubham-ghosh 4 ปีที่แล้ว

    hello.. i am from India. thanks for such a great explanation.

  • @domenicocucinotta2720
    @domenicocucinotta2720 3 ปีที่แล้ว

    First Time I really understood the this keyword! Thanks Mosh,you are a 🌟

  • @Allisondeluca
    @Allisondeluca 2 ปีที่แล้ว

    Thanks. Had to watch twice but now I understand.

  • @80Vikram
    @80Vikram 4 ปีที่แล้ว +8

    7:20 you've mentioned that's topic for next lecture. Please clarify where can I find "next lecture" ?

    • @Snoo29293
      @Snoo29293 4 ปีที่แล้ว +3

      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.

  • @arthurnino93
    @arthurnino93 4 ปีที่แล้ว

    Favorite tutor mentor in programming

  • @tyrodev5281
    @tyrodev5281 3 ปีที่แล้ว

    Now "this" is what I came for! Thanks Mosh!

  • @bibekkhatri
    @bibekkhatri 4 ปีที่แล้ว

    Mosh! your explanation is clear and concise.

  • @davidtran1360
    @davidtran1360 2 ปีที่แล้ว

    Great video. I fully undertand "this" now

  • @damian1310
    @damian1310 3 ปีที่แล้ว

    I learned something new today. I haven't idea that the second param of the forEach function could add the this keyword!

  • @relaxpinknoise
    @relaxpinknoise ปีที่แล้ว

    my instructor sucks in class, so thank you for explaining!!!

  • @ore_bear8045
    @ore_bear8045 4 ปีที่แล้ว

    superclass, this explanation of this is the best the world has ever seen.

  • @ingridblumenfeld8299
    @ingridblumenfeld8299 4 ปีที่แล้ว

    To me, you're like Forrest Gumps' momma. You always have a way of explaining things so I can understand them. THANK YOU

  • @haythamkenway8343
    @haythamkenway8343 4 ปีที่แล้ว

    This is the best explanation of 'this' keyword. Thanks a lot mosh 🙂

  • @itsthomasYT
    @itsthomasYT 6 ปีที่แล้ว

    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.

  • @priyamganguly
    @priyamganguly 4 ปีที่แล้ว

    A small, yet complex, topic made easy through this simple video. Thanks!

  • @nadhiffuadi
    @nadhiffuadi 3 ปีที่แล้ว

    Amazing! Thank you MOSH! and.... may i know where the next lecture is?

  • @alwyschwuetz
    @alwyschwuetz ปีที่แล้ว

    I finally understood how this keyword works!

  • @mikoaj2323
    @mikoaj2323 4 ปีที่แล้ว

    Thanks man! I understood after 3 minutes of ur video

  • @samsunnaharpanna
    @samsunnaharpanna ปีที่แล้ว

    Thanks for this simple and understandable video.

  • @benisaa1111
    @benisaa1111 4 ปีที่แล้ว +1

    Now I really get it omg...also with the 'new' keyword, many thanks!

  • @kaiwensun
    @kaiwensun 6 ปีที่แล้ว

    tl;dr:
    case 1:
    `this` in an object method -- referencing the object.
    case 2:
    `this` in a regular function -- referencing `window` (`global` in node.js)
    case 3 - a special case inferred from case 1:
    function Video() {console.log(this);}
    new Video;
    referencing a new `Video` object, because `new` creates an empty object `{ }` and `Video` serves as a constructor method of the object.
    case 4 - a special case inferred from case 2:
    `this` in a regular function in an obj method -- referencing `window` because `this` is in a regular function.
    case 1 at 1:00
    case 2 at 2:13
    case 3 at 2:33
    case 4 at 4:35
    Note: all the four cases above are based on the assumption that nothing is tampered with by things like `call`, `apply` and `bind`.

    • @kaiwensun
      @kaiwensun 6 ปีที่แล้ว

      a special case that the lecture does not mention:
      based on the code in case 3,
      function Video() {this.a = 1;}
      Video.prototype = {f: function() {console.log(this);}
      Video.prototype.f(); // print out the `prototype` with `f` inside.
      var v = new Video;
      v.f(); // print out the `v` with `a` inside.

  • @naumanraees2932
    @naumanraees2932 4 ปีที่แล้ว

    Mr. Mosh you are really great sir, your teaching style, explanation and your knowledge helped me a lot to clear my ideas

  • @faisal.fs1
    @faisal.fs1 4 ปีที่แล้ว

    Mosh is always a good teacher!!

  • @daniillitvinenko4348
    @daniillitvinenko4348 ปีที่แล้ว

    THIS IS INSANE. THANK YOU

  • @1vigneshram
    @1vigneshram 4 ปีที่แล้ว

    I really loved it mosh!!! very confused before now got clear understanding of how this works with practical knowledge

  • @_slier
    @_slier 2 ปีที่แล้ว

    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

  • @4aLse
    @4aLse 3 ปีที่แล้ว +1

    holy macaroni, thanks for the video!! wonderfully explained.

  • @kushalkumar4970
    @kushalkumar4970 4 ปีที่แล้ว

    Wow! You just taught me in first 1 min which I needed the most. Thanks a ton!

  • @michaelrosenfeld8055
    @michaelrosenfeld8055 3 ปีที่แล้ว

    Thank you so much for this. One simple sentence and it somewhat clicked for me.

  • @zdargahi
    @zdargahi ปีที่แล้ว

    thanks for great content, to avoid confusion 3:41 it would be better not to call the constructor function Video to not mix it with object video above.

  • @fidtran4991
    @fidtran4991 5 ปีที่แล้ว

    Thank you so much for this lecture. I watched a bunch of videos but still got confuse. With your clear clarifications I feel much more confident learning programming!!!

  • @christianpaul5224
    @christianpaul5224 4 ปีที่แล้ว

    try adding type="module" to the source of your index html and try to run with console log (this) in your javascript file that would be resulted in undefined.

  • @katiushka22
    @katiushka22 4 ปีที่แล้ว +1

    THIS was driving me crazy until I watched your video. Thanks!!!

  • @mdirshath4174
    @mdirshath4174 3 ปีที่แล้ว

    Thanks for the clear explanation. You really explain complex topics easily understandable. Thank you so much!!!

  • @rakeshkulkarni5552
    @rakeshkulkarni5552 3 ปีที่แล้ว +1

    Finally, I know this in Javascript,

  • @FarhanAli-hu8ie
    @FarhanAli-hu8ie 4 ปีที่แล้ว +2

    Where is the next lecture? I would like to know more about the other solutions that you mentioned at the end of this video.

    • @shangshi6286
      @shangshi6286 4 ปีที่แล้ว

      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.

  • @shaheryarmahmood247
    @shaheryarmahmood247 3 ปีที่แล้ว

    you can use now arrow function to reference the video object in the forEach.

  • @jitendrakhadoliya9582
    @jitendrakhadoliya9582 ปีที่แล้ว

    That was too clean 🔥🔥🔥

  • @mohdshoaib7622
    @mohdshoaib7622 ปีที่แล้ว

    best video to understand this keyword.

  • @jamesblock8384
    @jamesblock8384 4 ปีที่แล้ว

    anyone watching this now should also be aware of how this interacts with arrow functions. For instance, passing an arrow function into the tags.foreach method there is no need for the second argument of the foreach method.

  • @EvenAsChrist
    @EvenAsChrist 4 ปีที่แล้ว

    Best explanation so far

  • @Aarmaxian
    @Aarmaxian 6 ปีที่แล้ว

    Thanks. A very easy to understand and abundantly clear video.

  • @cauebahia
    @cauebahia 3 ปีที่แล้ว

    Sharp explanation! Thank you

  • @therealorberon
    @therealorberon 6 ปีที่แล้ว +2

    I need to watch and re-watch this a few times. to get and remember it.