Bind Explained in JavaScript

Поділитися
Вставка
  • Опубліковано 4 січ 2025

КОМЕНТАРІ • 239

  • @lev6666
    @lev6666 Рік тому +6

    Watched several videos with bind explanation, this is the best one. thanks!

  • @misterjedu
    @misterjedu 5 років тому +67

    This is the best explanation, simple and clear explanation I have seen.
    Thanks man

    • @dcode-software
      @dcode-software  5 років тому +2

      No worries, man

    • @suzanamiceli8309
      @suzanamiceli8309 3 роки тому

      @@dcode-software I have to agree with him! I was very confused about this and now I get it!! Thanks ♥

    • @MarstonH
      @MarstonH 6 місяців тому

      agreed. dcode is the best

  • @tonisihvola71
    @tonisihvola71 4 роки тому +16

    Easiest subscription of my life :)
    Your way of teaching is superior to anyone teaching these subjects, by far.
    - Breaking the topic into clear and understandable steps.
    - Going through the subject with simple examples, of how the code fundamentally works.
    - Explaining what happens, when the piece of code is not applied (Simply, not leaving any questions behind)
    Please, keep it up.

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

    This is one of the best javascript tutorial channels i've ever watched on UA-cam. You rock!

  • @tannerbarcelos6880
    @tannerbarcelos6880 4 роки тому +17

    This is literally the best video on bind() out there. I’m starting to slowly really get the quirky things of JS. You earned a sub. I’m gonna go watch more of your vids now!

  • @bbuiu
    @bbuiu 4 роки тому

    i am from Brazil, i bought a course in my language (portuguese) and i saw 4 times the explanation in my class and i can´t understand, so i come here and see you explanation, perfect i understand clearly, thanks!

  • @billychanclub8622
    @billychanclub8622 3 роки тому

    "Bind an object to a function" This makes so much sense now, that's exactly what I needed to understand this. Thanks!

  • @maceakkari2478
    @maceakkari2478 6 років тому +5

    By far the most simplest and most effective explanation out there. thank you

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

    Love how you went straight to the point. Great Job!

  • @pouvoircerveau7826
    @pouvoircerveau7826 6 років тому +22

    very clear explanation,great work man ,keep it up

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

    Thank You,. To the point, plain and clear. dcode is in my Top 5 for Tutorial Content Creators. Appreciate you dcode.

  • @premkatta1128
    @premkatta1128 5 років тому +2

    Great explanation, simple and straight to the point. This video should reach more people.

  • @sparshgupta8078
    @sparshgupta8078 5 років тому

    amazing explanation , no time wasting ,on to the point . that is what a learner needs

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

    Understood clearly finally about bind method. Best video for bind method

  • @ashuvssut
    @ashuvssut 4 роки тому

    This is a super simple and crystal clear explanation. Thanks for the MDN Link below... I was gonna google that anyway for... u know.. 'extras'😁

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

    The best explanation for bind method. Thanks sir. You should have more subscriber.

  • @mehra.akshit
    @mehra.akshit 5 років тому +4

    Very clear and to-the-point explanation. Thank you!

  • @ahora1026
    @ahora1026 6 років тому +6

    So everyone in the comments are right. This explanation is a bit different from the others.
    Simple, understandable and no confusing words.

    • @dcode-software
      @dcode-software  6 років тому +1

      Thank you! Very happy to hear it could help you 😁

  • @TimoEngelvaart
    @TimoEngelvaart 4 роки тому

    Was working on a React course and couldn't quite get my head around the use of 'this'. Thank you for your clear explanation.

    • @LotfiOR
      @LotfiOR 4 роки тому

      Same here. Coming from a React course. Saw many other videos. This one explains exactly what I needed to understand 🙂

  • @nikhilchandraroy1094
    @nikhilchandraroy1094 5 років тому

    I have seen stackoverflow that was little bit of difficult but you are so simple to teach us, keep up man,

  • @MohamedhabibBellaaj
    @MohamedhabibBellaaj 4 роки тому

    This is the best demonstration of the function bin I have seen. Thank you, man :)

  • @sreerup_dhrino
    @sreerup_dhrino 4 роки тому

    Bestest bind video.... Just what I was looking for..

  • @nerdiloo9863
    @nerdiloo9863 5 років тому +1

    The most succinct example of JS bind. Many thanks 👍.

  • @HologramJay
    @HologramJay 5 років тому

    Dude, thank you so much for this breakdown. I've taken courses from popular udemy teachers, only to have them gloss over confusing topics like these(Looking at you "Javascript : Understanding the Weird Parts"). Thanks again, man!

  • @madhvikathar6972
    @madhvikathar6972 3 роки тому

    Short and very clear explanation, Thank you!!!

  • @aligu7
    @aligu7 4 роки тому +1

    What if bind method has 2 arguments? for example : functionName.bind(arg1, arg2) ???? What does it mean. Plz some one help me

  • @gabrielfono844
    @gabrielfono844 4 роки тому +6

    damn I was stuck in react and didn't know
    thanks for finding this video on youtube

  • @arslanramay7992
    @arslanramay7992 5 років тому +1

    A very clear and to the point explanation. Great work. Thanks!

  • @carusosiza154
    @carusosiza154 4 роки тому

    Beautifully simple examples - thankyou.

  • @weitingtam
    @weitingtam 5 років тому

    Awesome video! Bind has been bugging me for months and the documentation isn't the clearest and I keep seeing and using it in tutorials but never really understood how it actually worked. Thanks for the clear explanation and helpful examples :)

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

    B-E-A-U-TIFUL! Thank you so much, dcode Narrator!

  • @gennieapulova8017
    @gennieapulova8017 5 років тому +2

    one of the best explanations of bind/this .. thank you!

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

    Straight to the point! Amazing video! Thank you!!!

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

    Great explanation. Simple and Clear. Thanks

  • @iQCudi
    @iQCudi 4 роки тому

    yo bro you tackled a mind block I had in a second, thank you so much. New sub.

  • @ubaidillah71
    @ubaidillah71 5 років тому +2

    Very good explanation. Thanks, im very confused before and now i can understand clearly 👌

  • @rdmammad5721
    @rdmammad5721 5 років тому

    Like... Super explained, but I do not understand one thing, why printCoordinates() (5:15) did not returned "undefined x,y error" messages?

  • @devinbuntin2123
    @devinbuntin2123 3 роки тому

    Super clear and concise explanation man, thanks! Subscribed. 🙏🏾

  • @bounce21190
    @bounce21190 4 роки тому

    Appreciate the in depth explanation, keep it coming!

  • @edinetgrunhed6000
    @edinetgrunhed6000 3 роки тому

    wow,im impressed with this simple explaination

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

    Would have liked to see you mention how call and apply relates to bind since they often get confused. Would also have been nice with some real-life examples of when bind is useful.
    Apart from that it's a good video!

  • @andideveloper8345
    @andideveloper8345 6 років тому +2

    Good work bro ! A unique explanation!

  • @mahmoudnasr8710
    @mahmoudnasr8710 4 роки тому

    Perfect Explanation .Keep up the Great Work

  • @trycatchlearn
    @trycatchlearn 6 років тому +1

    its crystal clear explanation, great job man

  • @marksimpson4310
    @marksimpson4310 4 роки тому

    Clear and concise explanation

  • @rod6722
    @rod6722 3 роки тому

    That was a very clear explanation. Thank you!

  • @bigbadcatbigbcy2933
    @bigbadcatbigbcy2933 2 місяці тому

    best video about bind method

  • @gargshishir3
    @gargshishir3 5 років тому +1

    Great job explaining bind! I finally understand it.

  • @abulkalamazad6022
    @abulkalamazad6022 5 років тому +1

    Thank you, DOM! You explained it well ☺️

  • @sahithivadla1187
    @sahithivadla1187 4 роки тому

    Such a clear and concise explanation. 👍

  • @makadibalazs
    @makadibalazs 5 років тому +1

    Ah, you saved me here man :). I was struggeling to understand this(lol)!

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

    Thank you, this was a really helpful, quick explanation

  • @philippalbrecht9023
    @philippalbrecht9023 5 років тому +2

    Anyone know a specific use case for this? Why not just pass the objects as parameters to the function?

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

      This use case could be applied when setting a regular function as an argument. If the regular function is not called as a method then this may not reference the object it is intended to reference. However, using an arrow function avoids the need to bind the this keyword. Also, sometimes you might want to use an object's method on a different object that doesn't have the method. TLDR, if you think the this will change dynamically you can use .bind anticipating the change and ensure the function executes referencing the correct object

  • @codingworld6762
    @codingworld6762 4 роки тому +1

    Very well explained!good work!!

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

    2 questions, Dom:
    1. Bind is only suitable where only 1 variable needs to be passed in a function?
    2. Is it necessary to use a variable to call function that way? I mean, directly calling functionName.bind(c1) should also call it?

  • @netuse4956
    @netuse4956 3 роки тому

    founded really wonderful explanation , loved it, found what i needed

  • @dexterwong3533
    @dexterwong3533 5 років тому +1

    awesome explanation... just a few words and got a light bulb moment. Great!

  • @ramusesandasari8451
    @ramusesandasari8451 6 років тому +2

    Last week I could not answer properly to this question When I attended interview , but now I can ...... Yeah .Thanks for this awesome video

    • @dcode-software
      @dcode-software  6 років тому +1

      No worries! Good luck for the interview 😁

    • @ramusesandasari8451
      @ramusesandasari8451 6 років тому

      Thanks .And can i know your name and about yourself

    • @omarchin-keow5319
      @omarchin-keow5319 6 років тому

      apprently that's a nope! >_

    • @kimonushki
      @kimonushki 4 роки тому

      @@ramusesandasari8451 Every video he says "My name is Dom ..." so there's half your question answered.

  • @BoredBricks
    @BoredBricks 3 роки тому

    Is there a way to use bind with ES6 style functions?

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

    Great explanation! Subscribed!

  • @limitless1692
    @limitless1692 4 роки тому

    Beautiful explication .
    You are GOLD
    Thank You ! :)

  • @sgamer1770
    @sgamer1770 4 роки тому

    if you use printCoordinates(c1), why does it output: 'undefined, undefined'

  • @thisisitmj1
    @thisisitmj1 3 роки тому

    Love it. Clear way to explain it!

  • @maremeaxi3344
    @maremeaxi3344 6 років тому +4

    the best video about bind(); ;))))

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

    what if we do c1_func = new printCoordinates.bind(c1);
    and then call c1_func() what happens in this?

  • @ranitdey7369
    @ranitdey7369 4 роки тому

    You explained it real nice. keep it up!

  • @amiladrck
    @amiladrck 4 роки тому +1

    Thank you! Straight to the point.

  • @annieluo6870
    @annieluo6870 3 роки тому

    thank you, you explained this so simply!

  • @seeprabu22
    @seeprabu22 5 років тому +1

    Crystal clear explanation. Thanks a lot.

  • @PJ-od9ev
    @PJ-od9ev Рік тому

    thank you. how about someFun.bind( null , 'some_arg' )
    what does it mean? what does it do? what is it for?

  • @henriquedeveloper8101
    @henriquedeveloper8101 4 роки тому

    Good explanation man, thank you!

  • @prateek4524
    @prateek4524 4 роки тому

    nice explanation 😊🔥🔥

  • @welcometochristown
    @welcometochristown 4 роки тому

    Very good explanation of bind. Thanks alot!

  • @abdoulabdoulmohaymen5
    @abdoulabdoulmohaymen5 4 роки тому

    Explained very good and simple.
    Thanks!

  • @benabernethy1405
    @benabernethy1405 3 роки тому

    Thank you man! Great explanation

  • @karthickchinnasamy1749
    @karthickchinnasamy1749 6 років тому +1

    Simple and clear explanation!

  • @passandscore_
    @passandscore_ 3 роки тому

    Awesome explanation!!!

  • @avimehenwal
    @avimehenwal 3 роки тому

    Now I am thinking what could be the use-cases where I can use bind? Please help, if you already have some use-cases where you have used js bind? thanks

    • @dcode-software
      @dcode-software  3 роки тому +1

      Bond is used less these days as arrow functions are now widely supported. But maybe you can use them with "addEventListener"?

  • @devendradeo518
    @devendradeo518 4 роки тому +1

    perfect example, thanks

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

    thanks a lot buddy, very nice explanation

  • @danvilela
    @danvilela 4 роки тому

    Excelent video! Thanks for this. What is the VS Code theme used?

  • @KelvinWKiger
    @KelvinWKiger 6 років тому +1

    Best explanation about the "Bind" statement.
    _const object_fr = {_
    _'prop_0': 'Merci',_
    _'prop_1': 'beaucoup',_
    _'prop_2': ' !',_
    _};_
    _const object_en = {_
    _'prop_0': 'Thank you',_
    _'prop_1': 'very much',_
    _'prop_2': '!',_
    _};_
    _const func = function name_func(argu) {_
    _return (this.prop_0 + ' ' + this.prop_1 + ' ' + argu + this.prop_2);_
    _}_
    _console.log(func.bind(object_en, 'Dom')());_

    • @dcode-software
      @dcode-software  6 років тому +1

      Hahaha! Thank you mate glad to see you enjoyed it 😁

  • @MiserableDuck95
    @MiserableDuck95 5 років тому +1

    Great explanation

  • @mahbubtonoy6974
    @mahbubtonoy6974 3 роки тому

    Coolest Explaination. Thank You

  • @dijiflex
    @dijiflex 4 роки тому

    thanks this was a very clear explanation

  • @AlexTechie
    @AlexTechie 5 років тому

    EDIT: Okay, I read the docs again, and it turns out that `bind()` creates a whole new function. You did mention that at 3:05, so I apologize (even though I didn't mean any ill will towards you). Still, I think it should be stressed that it creates a whole new function. This is a huge distinction between `bind()` and `call()` / `apply()`, which do not create a new function.
    ----
    2:52 That's a monumental step you glossed over and I was really hoping you would explain it, as even MDN doesn't discuss it. But I figured it out on my own after wondering why my lab example of `bind()` wasn't working. This is my understanding of it:
    `bind` is a method that sets a property on a function.
    If you try to run the function as `printCoordinates.bind(c1)`, nothing happens.
    If you try to run the function as `printCoordinates().bind(c1)`, it'll execute (with undefined on console.log outputs) and then give you a type error.
    For anyone reading: if you don't want to assign the function to a variable and, instead, just want to execute it immediately, the secret is to invoke the function by adding parenthesis at the of `bind()`. For example: `printCoordinates.bind(c1)();`

    • @dcode-software
      @dcode-software  5 років тому

      Yeah good explanation, appreciate the feedback! 🍻

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

    Great tutorial..is that the primary usage of the bind method? To bind objects to functions??

  • @mrxinu
    @mrxinu 5 років тому +1

    That was an excellent explanation. Thank you!

  • @tbethauser
    @tbethauser 5 років тому

    Excellent, so helpful!

  • @preciousadeyinka2786
    @preciousadeyinka2786 3 роки тому

    Thanks man, this is helpful!

  • @rashedxyz
    @rashedxyz 5 років тому +1

    Great explanation! Thanks

  • @gorank777
    @gorank777 3 роки тому

    Best explanation!

  • @alpercaner2923
    @alpercaner2923 5 років тому

    what about multiple parameters with bind?

  • @AK-Star007
    @AK-Star007 3 роки тому

    Great explanation, thanx

  • @blendjams
    @blendjams 4 роки тому

    Best explanation. Thanks :)

  • @GaneshKumar-fu7xt
    @GaneshKumar-fu7xt 4 роки тому

    easily understandable Thanks bro :)

  • @irinafedorova2763
    @irinafedorova2763 3 роки тому

    What is the use case for this?

  • @shrestha0144
    @shrestha0144 4 роки тому

    straightforward..thanks

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

    Great video. I'm not sure why this would be better than just passing in an object though?

  • @muhammadainuddin4650
    @muhammadainuddin4650 4 роки тому

    Great explanation, Thanks