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.
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!
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!
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!
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 :)
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!
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
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?
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
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)();`
Watched several videos with bind explanation, this is the best one. thanks!
This is the best explanation, simple and clear explanation I have seen.
Thanks man
No worries, man
@@dcode-software I have to agree with him! I was very confused about this and now I get it!! Thanks ♥
agreed. dcode is the best
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.
Appreciate that! Thank you very much
This is one of the best javascript tutorial channels i've ever watched on UA-cam. You rock!
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!
I appreciate that! Cheers :)
Hey man. Hoping that you’re a full stack monster now!!❤
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!
"Bind an object to a function" This makes so much sense now, that's exactly what I needed to understand this. Thanks!
By far the most simplest and most effective explanation out there. thank you
No probs mate, thank you!
Love how you went straight to the point. Great Job!
very clear explanation,great work man ,keep it up
No worries mate, thank you.
Thank You,. To the point, plain and clear. dcode is in my Top 5 for Tutorial Content Creators. Appreciate you dcode.
Great explanation, simple and straight to the point. This video should reach more people.
My pleasure mate
amazing explanation , no time wasting ,on to the point . that is what a learner needs
Understood clearly finally about bind method. Best video for bind method
Thank you 🙏
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'😁
The best explanation for bind method. Thanks sir. You should have more subscriber.
Very clear and to-the-point explanation. Thank you!
No probs!
So everyone in the comments are right. This explanation is a bit different from the others.
Simple, understandable and no confusing words.
Thank you! Very happy to hear it could help you 😁
Was working on a React course and couldn't quite get my head around the use of 'this'. Thank you for your clear explanation.
Same here. Coming from a React course. Saw many other videos. This one explains exactly what I needed to understand 🙂
I have seen stackoverflow that was little bit of difficult but you are so simple to teach us, keep up man,
This is the best demonstration of the function bin I have seen. Thank you, man :)
Bestest bind video.... Just what I was looking for..
The most succinct example of JS bind. Many thanks 👍.
No probs mate!! 🍻
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!
Short and very clear explanation, Thank you!!!
What if bind method has 2 arguments? for example : functionName.bind(arg1, arg2) ???? What does it mean. Plz some one help me
damn I was stuck in react and didn't know
thanks for finding this video on youtube
me too :))
A very clear and to the point explanation. Great work. Thanks!
My pleasure mate!
Beautifully simple examples - thankyou.
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 :)
B-E-A-U-TIFUL! Thank you so much, dcode Narrator!
one of the best explanations of bind/this .. thank you!
No probs :) glad you liked it
Straight to the point! Amazing video! Thank you!!!
Great explanation. Simple and Clear. Thanks
yo bro you tackled a mind block I had in a second, thank you so much. New sub.
Very good explanation. Thanks, im very confused before and now i can understand clearly 👌
No problem!
Like... Super explained, but I do not understand one thing, why printCoordinates() (5:15) did not returned "undefined x,y error" messages?
Super clear and concise explanation man, thanks! Subscribed. 🙏🏾
Appreciate the in depth explanation, keep it coming!
Thanks, will do!
wow,im impressed with this simple explaination
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!
Good work bro ! A unique explanation!
Thank you! I hope it helped 😁
Perfect Explanation .Keep up the Great Work
its crystal clear explanation, great job man
No problem mate!
Clear and concise explanation
That was a very clear explanation. Thank you!
best video about bind method
Great job explaining bind! I finally understand it.
Glad I could help you mate
Thank you, DOM! You explained it well ☺️
Such a clear and concise explanation. 👍
Ah, you saved me here man :). I was struggeling to understand this(lol)!
Thank you, this was a really helpful, quick explanation
Anyone know a specific use case for this? Why not just pass the objects as parameters to the function?
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
Very well explained!good work!!
No problem!
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?
founded really wonderful explanation , loved it, found what i needed
You're welcome
awesome explanation... just a few words and got a light bulb moment. Great!
Yeh mate no worries!! 😁
Last week I could not answer properly to this question When I attended interview , but now I can ...... Yeah .Thanks for this awesome video
No worries! Good luck for the interview 😁
Thanks .And can i know your name and about yourself
apprently that's a nope! >_
@@ramusesandasari8451 Every video he says "My name is Dom ..." so there's half your question answered.
Is there a way to use bind with ES6 style functions?
Great explanation! Subscribed!
Beautiful explication .
You are GOLD
Thank You ! :)
if you use printCoordinates(c1), why does it output: 'undefined, undefined'
Love it. Clear way to explain it!
the best video about bind(); ;))))
You're welcome
what if we do c1_func = new printCoordinates.bind(c1);
and then call c1_func() what happens in this?
You explained it real nice. keep it up!
Thank you! Straight to the point.
thank you, you explained this so simply!
Crystal clear explanation. Thanks a lot.
No problem, mate
thank you. how about someFun.bind( null , 'some_arg' )
what does it mean? what does it do? what is it for?
Good explanation man, thank you!
nice explanation 😊🔥🔥
Very good explanation of bind. Thanks alot!
No problem!
Explained very good and simple.
Thanks!
No problem
Thank you man! Great explanation
Simple and clear explanation!
Thanks mate, that's the goal 😁
Awesome explanation!!!
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
Bond is used less these days as arrow functions are now widely supported. But maybe you can use them with "addEventListener"?
perfect example, thanks
No worries 😊
thanks a lot buddy, very nice explanation
Excelent video! Thanks for this. What is the VS Code theme used?
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')());_
Hahaha! Thank you mate glad to see you enjoyed it 😁
Great explanation
Glad you liked it mate
Coolest Explaination. Thank You
thanks this was a very clear explanation
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)();`
Yeah good explanation, appreciate the feedback! 🍻
Great tutorial..is that the primary usage of the bind method? To bind objects to functions??
That was an excellent explanation. Thank you!
No worries mate
Excellent, so helpful!
Thanks man, this is helpful!
Great explanation! Thanks
No problem 😀
Best explanation!
what about multiple parameters with bind?
Great explanation, thanx
Best explanation. Thanks :)
easily understandable Thanks bro :)
What is the use case for this?
straightforward..thanks
Great video. I'm not sure why this would be better than just passing in an object though?
Great explanation, Thanks
No worries