call, apply and bind are predefined methods in javascript and its very using to handle this keyword .
this keyword work quiet differently in javascript as compared to other object oriented language and that creates confusion for the programmers.
Function borrowing allows us to use the methods of one object on a different object without having to make a copy of that method and maintain it in two separate places. It is accomplished through the use of .call(), .apply(), or .bind(), all of which exist to explicitly set this on the method we are borrowing.
There are many benefits to method borrowing:
It prevents the unnecessary duplication of code.
It allows the user to use methods of different objects without inheriting.
Using method borrowing prevents the replication of methods in multiple object blocks and saves time.
call, apply and bind method is just to implement method borrowing, where we can use explicitly specify what this should reference within the calling function.
In this video, I have explained how you should write your functions so that you can optimised your code and can clear the coding round during your interview.
Support my channel so that I can reach to wider audience. Please share it in your network 🙏
Connect with me on social platform:
Facebook: [ Ссылка ]
LinkedIn: [ Ссылка ]
Instagram : [ Ссылка ]
For more such interesting videos, please subscribe to my channel and stay connected.
#javascript #NishaSingla #callapplybind
Ещё видео!