• Sunday , 19 November 2017

JavaScript Bind in 5 Minutes

Code Canyon



To learn more advanced Web Development techniques, sign up for my brand new course on TypeScript at Udemy. https://www.udemy.com/typescript/?couponCode=TYPESCRIPT_NOW

Bind is a super useful (and confusing) native feature of JavaScript.
Not so sure about bind? Let this 5 minute tutorial show you how it’s done!

Original source

3d Ocean

Related Posts

28 Comments

  1. alberto hernandez
    August 31, 2017 at 07:52

    Many many thanks ! I have seen this topic several times but never like your explanation ! 🙂

  2. Makoto Saito
    August 31, 2017 at 07:52

    Thanks a lot!

  3. איתי מצליח
    August 31, 2017 at 07:52

    Thank you very much.
    Couldn't explain it more simple than this.
    Much appreciated!

  4. Seppänen Juho
    August 31, 2017 at 07:52

    Thanks alot!

  5. Eric K
    August 31, 2017 at 07:52

    Thanks!

  6. Daniel Hernández
    August 31, 2017 at 07:52

    Thanks a lot.

  7. Uncontrollable Love
    August 31, 2017 at 07:52

    correct me if I am wrong but, bind is giving me flexibility to create a generic function that does something regardless of its context. When we invoke bind and pass in a value, it changes the context and perform its function/operation on the context provided.

  8. Jason Berry
    August 31, 2017 at 07:52

    You talk fast – I have to keep pausing it to keep up 🙂

  9. Lute Scrat
    August 31, 2017 at 07:52

    great example and well explained

  10. hotleg777
    August 31, 2017 at 07:52

    Can I ask why you wouldn't just pass in the object as a parameter for showName? As in:

    function showName(obj){
    return obj.name;
    }

    Then call:
    showName(a);

    Maybe I'm not looking far enough into the application of bind. But why use bind instead of writing a more versatile function?

  11. Jaymesh Vyas
    August 31, 2017 at 07:52

    Please, don't use a word 'confusing'. It is not a confusing concept.

  12. Brian Jin
    August 31, 2017 at 07:52

    you are good at teaching things and making it click! I was losing my mind trying to learn this and apply it in refactoring of my older project thanks!

  13. conor budge
    August 31, 2017 at 07:52

    Stupid question, but how do you type a new line in the Chrome console? When I press ENTER it enters the command.

  14. Pedro Leite
    August 31, 2017 at 07:52

    I'd tried many different books, videos, and websites, but none of them could show how bind works in a simple enough way. You've done that. Great job.Thanks.

  15. Jorge Chavez
    August 31, 2017 at 07:52

    So whatever I pass to the bind function, it replaces 'this' into that function?

  16. thinh nham
    August 31, 2017 at 07:52

    very informative and straight forward ! Javascript is a powerful language but has been underestimated by programmers who do not know much about web development !

  17. VyperDOS
    August 31, 2017 at 07:52

    Very helpful!

  18. VyperDOS
    August 31, 2017 at 07:52

    Thanks! Can you please make "applly" and "call" in 5 minutes?

  19. Alex Bravo
    August 31, 2017 at 07:52

    Thanks dude

  20. Data Whore
    August 31, 2017 at 07:52

    thank you for this. .bind is something i just seem to forget in my coding and waste waaay to much time with weird errors

  21. Inbarasan Kannadhasan
    August 31, 2017 at 07:52

    Nice.. thank you very much

  22. rasmus00666
    August 31, 2017 at 07:52

    so "bind" is like making the function you bind a method to the particular object you pass into it as an argument? because if I do something like a.showName = showName.bind(a) it is practically a method. Or am I confusing something?

  23. Konstantin Ryzhov
    August 31, 2017 at 07:52

    Ctrl + L => to clear chrome devtools console log 🙂
    Awesome lessons, thanks a lot.

  24. NORDEEN awesu
    August 31, 2017 at 07:52

    I take it you're a GOT fan?

  25. YuTenHeim
    August 31, 2017 at 07:52

    Very useful. Thanks!

  26. Mike Rotch
    August 31, 2017 at 07:52

    I know that the "this" in following refer to window. So it will give an error.
    Var a = { method : 'jump',
    Call: this.method}
    But why does the example you gave with this used inside a function return the Object? Can you help this out?

  27. gleb bahmutov
    August 31, 2017 at 07:52

    The confusion in large part stems from the fact that bind does two things in JavaScript: context binding and partial application. http://glebbahmutov.com/blog/binding-vs-partial-application/

  28. Jan De Wilde
    August 31, 2017 at 07:52

    Little typo: cmd-option-i opens devtools.

Leave A Comment

You must be logged in to post a comment.