What is THIS keyword in JavaScript? - Tutorial for beginners

Поділитися
Вставка
  • Опубліковано 27 чер 2024
  • What is the THIS keyword in JavaScript? How does it work and why is it so confusing?
    The THIS keyword, from the series "10 Things JS Developers Should Know"
    by ColorCode.io, Sina Jazayeri
    Full playlist here: • 20 Things JavaScript D...
    This is episode 6 in a 10 part series I’m calling 10 things javascript developers should know but probably don’t. In this series, we’re going to cover some of the most fundamental and important parts of JavaScript that most of us don’t actually know, and barely touch. Today, for episode 6, we’re talking about the THIS keyword, how context and execution logic changes the value of the this keyword, and how arrow functions affect the value? Episode 6: The THIS keyword. Let’s go!
    All the code from this series is available here:
    github.com/ColorCode/js-10-th...
    0:00:00 Intro
    0:00:53 THIS in Global scope
    0:01:40 THIS inside functions (methods)
    0:06:25 Function.bind
    0:10:03 Function.call
    0:16:10 Function.apply
    0:16:42 THIS inside Constructor functions
    0:20:00 THIS inside callback functions
    0:23:40 THIS inside arrow functions
    0:24:26 Conclusion

КОМЕНТАРІ • 277

  • @ColorCodeio
    @ColorCodeio  3 роки тому +45

    JavaScript THIS keyword explained - A deep dive 👨🏻‍💻

    • @arod3295
      @arod3295 3 роки тому +1

      So I have a very important question. PLEASE help. So there must be more to the layers of seniority I should say to the concept of front vs backend…there’s more job titled for a coder of all levels. What are those many titles called?
      Web developer
      Front end
      Back end
      Web designer
      Programmer (which idk if that’s just another word for web dev or if that’s a proper title)
      Junior developer (idk if that’s another word for entry front end)
      What other titles are there? Knowing this would help people find a proper path to get started instead of aiming high like “I want to be a software developer” like I did 3yrs ago. Now I’m aiming for front end (if that’s right) and design web logic to interact with smart contracts (I want to work in the blockchain industry and a lot of the work is programming websites to interact with the contracts)
      Thank you

    • @starkxz
      @starkxz Рік тому

      @@arod3295
      There are many job titles and roles within the world of software development. Here are some common ones:
      Full-stack developer: a developer who can work on both the front-end and back-end of an application.
      Mobile developer: a developer who specializes in building applications for mobile devices.
      Game developer: a developer who specializes in building video games.
      DevOps engineer: a developer who works on the development and deployment of software through collaboration with software developers and IT professionals.
      Software engineer: a developer who designs, builds, and tests software applications.
      QA engineer: a developer who is responsible for testing software applications to ensure that they function properly.
      UX/UI designer: a designer who specializes in creating user interfaces and experiences for software applications.
      Product manager: a professional who oversees the development and management of a software product.
      Technical writer: a professional who creates documentation and user guides for software applications.
      It's important to note that some of these roles may require more specialized knowledge or experience in a particular area. For example, becoming a mobile developer may require knowledge of specific programming languages and frameworks, as well as experience with mobile app development.
      Ultimately, the best way to determine which role is right for you is to explore the different areas of software development and see which ones interest you the most. Consider taking online courses or tutorials, attending meetups or conferences, and talking to professionals in the field to learn more about the different roles and how you can get started in your desired career path.

  • @cleanocavalcante
    @cleanocavalcante 2 роки тому +77

    Dear UA-cam's Algorithm gods, please bless this channel with a million views per episode 🙏🏼😁. This content is absolutely gold. I've been learning JS for the past 2 months and I'm really benefitting from all this knowledge. Thank you so much, and keep up the fantastic work! Cheers from Brazil!

    • @ColorCodeio
      @ColorCodeio  2 роки тому +10

      Haha this is the best comment I ever got. Thank you. I'm glad these videos are helping. Message me on instagram if you have questions.

    • @cleanocavalcante
      @cleanocavalcante 2 роки тому +1

      @@ColorCodeio You 100% deserve it!

    • @omersoncruz1081
      @omersoncruz1081 Рік тому

      Amen!

    • @uzgurCoder
      @uzgurCoder 10 місяців тому +1

      Your wish granted😁😅😅

  • @darksoulgamer5837
    @darksoulgamer5837 2 роки тому +45

    This is an underrated channel! The explanation is mind blowing not confusing at all, please keep making videos on JS 🙏

    • @ColorCodeio
      @ColorCodeio  2 роки тому +4

      Great to hear that! More videos coming soon.

    • @redeye8536
      @redeye8536 17 днів тому

      @@ColorCodeio lol i really like this thank you lolllll xddddd

  • @atlas8133
    @atlas8133 2 роки тому +14

    'This' video should have at least 100 times more views. Pure gold if you've ever been confused about the intricate applications of 'this' in different contexts. He also covers .bind, .call, .apply as a nice bonus. My favorite video about 'this', simple as 'that'!

  • @axkongkong2819
    @axkongkong2819 Рік тому +4

    I watched your video on THIS...didn't understand anything......then i watched 10 other random videos on UA-cam about THIS....did not understand anything. I gave up and went on with my day. The next day your 1 min video on THIS popped up, i watched that, and that was clear as day!!!! I followed up by watching this 24 min video, and everything was so clear!! I don't know if its just the time it took for information to absorb over 24 hours or i re-watched your videos a few times like you said at the end, in order to get it. One thing is for sure, this is the best tutorial on THIS and i am pretty sure i watched them all. Love your teaching style, very good examples and slight humor sprinkled around. Subscribed!

    • @ColorCodeio
      @ColorCodeio  Рік тому +1

      That's awesome! Thanks for sharing and I'm glad it clicked.

  • @RossieeissoR
    @RossieeissoR 2 роки тому +4

    Style, pace, music, explanation, effects, even typing sound... everything is perfect.

  • @Flipping_myFinds
    @Flipping_myFinds 3 роки тому +4

    Always liked creating and designing. Programming is a new journey that I’m taking (haven’t had really good inexpensive sources to learn from)and I’m super glad I found you and I know your videos and courses will guide me finally the right way

    • @ColorCodeio
      @ColorCodeio  3 роки тому +2

      Great to hear! Best of luck in your journey and reach out to me if you have questions.

  • @digitalfragrant
    @digitalfragrant 3 місяці тому +2

    The most underrated educator on YT. Production quality is also insane. Keep it up man!

  • @salamina_
    @salamina_ 2 роки тому +1

    Excellent explanations on subjects have always been a mystery to me. Thank you for making these tutorials, really insightful and entertaining.. dig your teaching
    style. Keep them coming!

    • @ColorCodeio
      @ColorCodeio  2 роки тому

      I appreciate that. Thank you 👍

  • @prakharpaw-de7vh
    @prakharpaw-de7vh Рік тому +1

    came here looking for explanation on the original f***ing a**hole of JavaScript, aka the this keyword. Ended up watching the entire series.
    Thank you

  • @asadmoosvi
    @asadmoosvi 2 роки тому +4

    Love these videos! You explain concepts really well and in great detail.

  • @dipankarsahoo7119
    @dipankarsahoo7119 Рік тому +1

    i watched a single video of yours and fell in love with your way of teaching, the background music, the humor everything loved it ..! subscribed

  • @myashkov1975
    @myashkov1975 Рік тому +1

    Simple, clear and perfect for beginners explanation of 'this' keyword, thanks, man!

  • @starkxz
    @starkxz Рік тому +1

    This channel is the best when it comes to JS. Honestly it needs more views. Thanks Sina, keep up the fantastic work.

  • @neria15
    @neria15 5 місяців тому +1

    this playlist need to be everywhere !
    Thank you Sina!

  • @kurisu26
    @kurisu26 8 місяців тому

    Best "this" tutorial I found. Thanks

  • @Fred-my9er
    @Fred-my9er Рік тому +1

    This was so well explained with good examples. I probably need to rewatch it to remember everything but I understood it all.

  • @nnex5
    @nnex5 Рік тому +1

    This channel and Web Dev Simplified are the most helpful channels for Web Developers. Thank you!

  • @syedaun5410
    @syedaun5410 2 роки тому +1

    Please keep going with your videos.
    You are really easy to understand and fun to watch.

  • @ebcoutinho
    @ebcoutinho 4 місяці тому +1

    These videos are helping me to fill the knowledge gaps I have

  • @towhid6476
    @towhid6476 Рік тому +1

    Loved the video explanation. I was following a JS course for a month and this one dominates all

  • @jatilyadav4000
    @jatilyadav4000 Рік тому +1

    Content is just amazing I could'nt stop watching

  • @user-vv5kw1ku2q
    @user-vv5kw1ku2q 5 місяців тому

    What a great job, you're doing!

  • @irenashovel9244
    @irenashovel9244 Рік тому

    this is amazing! thank you so much for this deep dive!

  • @alainkaiser2697
    @alainkaiser2697 10 місяців тому +1

    this is better than 99% of the blog posts out there trying to explain core concepts like this!

  • @stepanterechshenko5435
    @stepanterechshenko5435 Рік тому +1

    best explanation of "this" I have found and I was looking in 3 different languages on YT

  • @namanjoshi5089
    @namanjoshi5089 10 місяців тому

    gold mine which isn't known by many .. love this channel

  • @chrismills5307
    @chrismills5307 8 місяців тому +1

    Amazing video, clear explanation, great communication and presentation skills, and covers all the ins and outs without making it overly complex.

  • @nynzxoxo
    @nynzxoxo 3 роки тому +3

    You deserve so many more views and subs! This content is gold

  • @MarstonH
    @MarstonH 9 місяців тому +1

    dude you are so real and good at explaining. this has helped a lot

  • @RAJVEERBIRADAR360
    @RAJVEERBIRADAR360 27 днів тому +1

    i was confused in this from aproximately 1yr i was just asuming it not understanding it true meaninig. thanks to you i was completely able to understand the topic this, (same concept self in python)

  • @TheAmanpro
    @TheAmanpro 3 роки тому +1

    Thank you so much! Beautifully explained. Keep posting

    • @ColorCodeio
      @ColorCodeio  2 роки тому

      Thank you, Aman :) More coming next week.

  • @HarelYeh...
    @HarelYeh... 9 місяців тому +1

    Really thanks for all the effort, it's really fun to watch and learn from you, you convey it in a pleasant way and not like a robot or excessive seriousness, just a pleasure.

  • @erickchavez4551
    @erickchavez4551 11 місяців тому

    Nicely explained! thanks for the amazing quality of your videos. Took a bunch of notes to review after watching the video.

  • @stevecrabtree9141
    @stevecrabtree9141 Рік тому +1

    Just found your channel, you would be a blast to work with! I would be dying all day with your humor

  • @user-kn4oi9oh4i
    @user-kn4oi9oh4i 3 місяці тому

    Best explanation! I swear to god, this is amazing

  • @abhijeetbajpai1022
    @abhijeetbajpai1022 5 місяців тому +1

    Dude, I really love the way of teach things, Really Awesome !! The hat's off to you.

  • @thiagoneves50
    @thiagoneves50 2 роки тому +2

    This is really good! I'm very grateful!

  • @BHASKARARAOKONNA
    @BHASKARARAOKONNA Рік тому

    Your explanation and presentation of the video are so good that I couldn't even wait to share this to my fellow learners and also SUBSCRIBED. Really, you should have got more views and subscribers. Keep up the good work 😀😎🙏

  • @taunado
    @taunado Рік тому +1

    Great production and all, thanks for sharing. +1 for providing purposeful and real-world use-case cases to provide the context for your teaching. My brain is constantly trying to work out the end goal and why what you're teaching has value, making it difficult to follow along.

  • @michaelnorton9715
    @michaelnorton9715 8 місяців тому

    Our WDD 330 Fundamentals of Web Development class at Brigham Young University - Idaho has this video as part of our notes! I like how you explained all of "this" ;) I enjoyed your video start and your energy throughout the video. I got lost on that last part where you set a time-out but I felt like I understand how to use "this" better than I did before. I need to watch your arrow function video. That's one thing that I get tripped up with. Thanks for all the time and work you put into making this video. Liked and subscribed!

  • @slaincore
    @slaincore Рік тому +1

    You are just awesome explainer/teacher! Keep going my friend!

  • @ivo_sa
    @ivo_sa 6 місяців тому +2

    man, i love your videos ! they are incredibly informative and also funny to watch !

  • @steelmantv
    @steelmantv Рік тому

    Thank you! So helpful

  • @pushkarkumar5578
    @pushkarkumar5578 Рік тому

    love you man great work.

  • @error0803
    @error0803 2 роки тому +1

    Very good and very high quality video. Thank you. Learned a lot👍🏻

    • @ColorCodeio
      @ColorCodeio  2 роки тому

      Awesome. You’re welcome 👍

  • @PatelBhaveshgo4glory
    @PatelBhaveshgo4glory 2 роки тому +1

    Amazing explanation. Keep it up, sir!

  • @uncoding_with_raj
    @uncoding_with_raj Рік тому +1

    Amazing tutorial man.

  • @MishraXE
    @MishraXE Рік тому

    The best explanation of This 😍

  • @himanshuarora1910
    @himanshuarora1910 Рік тому +1

    i really liked it when i can see the person who is teaching ,great work

  • @havefun5519
    @havefun5519 Рік тому +1

    Cool explanation. BTW, the video quality is great, and the speed of the talk is good, like the clear accent.

  • @dineshreddy8915
    @dineshreddy8915 Рік тому +1

    perfect, everything is perfect....
    The concept , the video, editing , making us attracted, every thing is perfect
    expecting more video from you (react if possible)

  • @programmingforfun4158
    @programmingforfun4158 Рік тому

    I dont know how this type of content can only have 25k views

  • @YeetYeetYe
    @YeetYeetYe Рік тому +2

    Great editing.

  • @santhoshk9285
    @santhoshk9285 3 роки тому +2

    keep rocking saanaaaaaaaa ... waiting for more 🔥

  • @IlPandax
    @IlPandax 4 місяці тому +1

    As an italian brother, your italian is perfect! And also your Javascript! XD

  • @ann_uken
    @ann_uken Рік тому +1

    Thank you for the video, very well explained! 💥

  • @jimkk159
    @jimkk159 Рік тому +1

    So good, help me a lot!!

  • @nathalianobrega6917
    @nathalianobrega6917 2 роки тому +1

    this is such a great video, thanks!

  • @sudiptasaha8905
    @sudiptasaha8905 Рік тому +1

    Hey, your content really adds value to my skillset. Please do make more videos. Love from India ❤

  • @andresfelipeladinoespitia
    @andresfelipeladinoespitia 9 місяців тому +1

    Thank you very much man. I had to watch it a couple of times, but I finally got the whole *this* concept. Also, you sound 100% like Edward Snowden.

  • @oneofone_1333
    @oneofone_1333 2 роки тому +1

    Man i stubbled on your content, love it!!!! Greetings from Switzerland

    • @ColorCodeio
      @ColorCodeio  2 роки тому +1

      Awesome. Thank you. One of my favorite places 🇨🇭

    • @oneofone_1333
      @oneofone_1333 2 роки тому

      @@ColorCodeio Ma man!

  • @yarinvanzikri
    @yarinvanzikri 2 роки тому +1

    love your content and attitude! am here just to say thanks!

  • @ayushdixit8993
    @ayushdixit8993 Рік тому +1

    You are great man!!!!!!!... Very well explained....
    Thanks

  • @user-lp5tk8tp6e
    @user-lp5tk8tp6e 10 місяців тому +1

    Thank you very much:) love your sense of humor;)

  • @surf2553
    @surf2553 Рік тому +1

    Yep, super helpful!

  • @user-mw5bm2xh9x
    @user-mw5bm2xh9x 8 місяців тому +1

    good stuff. thanks

  • @tetianazhuchenko2182
    @tetianazhuchenko2182 Рік тому +1

    Your expectations are great 👍 Thanks

  • @edhead76
    @edhead76 5 місяців тому

    Is bind only used with the keyword 'this'? This is a great explanation, but I had to pause and rewind several times to grasp the concept more fully. Actually, to clarify, this is the BEST explanation I've come across, and I have been searching for the correct way to use 'this' for quite some time!

  • @aballahsameh3597
    @aballahsameh3597 Рік тому +1

    So cool!

  • @Genesis0_o
    @Genesis0_o 8 місяців тому

    You're a Legend

  • @aoniatraxler6897
    @aoniatraxler6897 2 роки тому +1

    This is awesome, thanks :)

  • @ayman3711
    @ayman3711 Рік тому

    great effort

  • @anuragsingh-ts3nb
    @anuragsingh-ts3nb 2 роки тому +1

    best instructor which u cannot even get on paid course, after watching this i became his big FAN!!😊

  • @X82oo781
    @X82oo781 5 місяців тому

    love this channel

  • @dream5.2
    @dream5.2 10 місяців тому

    'This' is too good. I'll never choose that

  • @randyafriansyah9340
    @randyafriansyah9340 Рік тому +1

    instant subscribe, this channel is really emazing

  • @chriskasatka2095
    @chriskasatka2095 2 роки тому +1

    Amazing channel!

  • @user-vo8hn7yj7z
    @user-vo8hn7yj7z 10 місяців тому

    Great explanation! By the way, what actually is the favorite feature mentioned in 2:54 ?

  • @taylorwade1537
    @taylorwade1537 Рік тому +1

    .this is awesome and THIS is awesome. Thank you so much!!

  • @alirezarezaei7416
    @alirezarezaei7416 2 роки тому +1

    Thanks a lot. after a lot of exhausting search, i realized this keyword.

  • @darksoulgamer5837
    @darksoulgamer5837 2 роки тому +2

    Love these videos, but could you also share some real world use cases? Like for call, apply,bind etc. Even for this, why do we really need it

  • @MuhammadUsman-fl7lo
    @MuhammadUsman-fl7lo Рік тому +1

    The channel needs more support !

  • @nathanisong9393
    @nathanisong9393 2 роки тому +1

    I love how you interact even though I am not still cool with it yet. But thanks

  • @tonydaian8036
    @tonydaian8036 2 роки тому +1

    Great content!

  • @Professor-eu1ll
    @Professor-eu1ll 11 місяців тому +1

    2nd best channel after ColorCode. Oh wait this is ColorCode

  • @WaseemAbbas-lv5xm
    @WaseemAbbas-lv5xm 3 місяці тому

    Awesome i love this course ❤ . Also make a tutorial on React

  • @by2313
    @by2313 3 роки тому +3

    I really like your classes. I'm using them in conjunction with a UDemy course and learning it from a couple folks is helping it sink in a bit more. I hope you do one on the Reduce method.

    • @ColorCodeio
      @ColorCodeio  3 роки тому +1

      Awesome. I may do one in August

    • @davidmmadden
      @davidmmadden 2 роки тому

      @@ColorCodeio would also love one on reduce!

  • @weiguo2297
    @weiguo2297 Рік тому +1

    Nice video. Help me to solve my confusion about the meaning of this in JSX callbacks.

  • @szanka96
    @szanka96 Рік тому +2

    I'm amazed that THIS can be explained without causing a headache. Hit the subscribe button. Thank you so much :)

  • @longingbydesign
    @longingbydesign 3 роки тому +1

    Thank you for your amazing videos. Please consider dropping the use of the non-standard innerText in favor of the standard textContent as many of your less experienced viewers will pick up that otherwise. innerText has its place (preserving linebreaks and whitespace), but in your examples its really all about textContent.

    • @ColorCodeio
      @ColorCodeio  3 роки тому +1

      Thanks for the comment. You obviously pay close attention to detail :)

  • @hunin27
    @hunin27 7 місяців тому +2

    you look like tony stark and i find it amazing

  • @mohamedmahmoud-nj1uh
    @mohamedmahmoud-nj1uh 5 місяців тому +1

    your videos are amazing , you give tricky tips when you code , in a smpile ways , please make it 100 things you might don't knoOoOoOow in JS

  • @TottiBln
    @TottiBln 2 роки тому +1

    Thank You!!! Greetings from Germany, Berlin!

  • @razzchaudhary9184
    @razzchaudhary9184 3 роки тому +1

    Amazing !!

  • @hustle4902
    @hustle4902 8 місяців тому +1

    You will definitely go to heaven bro💯

  • @boooloool6039
    @boooloool6039 2 роки тому +1

    Subscribed! because you said " i am qoli" amazingly 😀 and of course such a good video!

  • @sharonh387
    @sharonh387 4 місяці тому +1

    Thanks!

  • @HosseinBajan
    @HosseinBajan 16 днів тому +1

    آقا دمت گرم عالی بود ❤

  • @Chris2phaBrown
    @Chris2phaBrown 3 роки тому +2

    Looking forward to the arrow function gotchas