Polyfill for bind method | Javascript Interview Questions

Поділитися
Вставка
  • Опубліковано 3 гру 2024

КОМЕНТАРІ • 290

  • @ruchirai5775
    @ruchirai5775 5 років тому +154

    @Akshay before this video I went through lot of blogs like medium, stackoverflow to understand binds internal implementation, this is the most easiest and awesome explanation I have ever seen for BIND.Thank you so much :) Can you also make a video on implementing own promise and implementing own virtual DOM ?

    • @pioneer7161
      @pioneer7161 2 роки тому +7

      medium pe bass gyaan milta hai.. real life scenario nhi milne wale..
      akshay bhai k liye meri taraf se 2 likes

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

      @@pioneer7161 bhai 2 likes mat kar ek hi kar 2 karega toh jo ek kiya woh Bhi hat jayega😜😜

  • @pranitapanigrahi3517
    @pranitapanigrahi3517 3 роки тому +7

    I do have knowledge on Javascript concepts but whenever I want to prepare for interviews or want to refresh my understanding about those concepts ,your youtube channel is the first thing which comes to my mind. I cant stop thanking you for sharing your knowledge in such a detailed way.

  • @abhishekmulay759
    @abhishekmulay759 3 роки тому +31

    Dude you are amazing! I am a senior engineer and I know all these concepts I still come back to your videos to refresh my knowledge before interviews! Keep up the great work.

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

      How does this variable refer printName method inside myBind function? I am confused here.

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

      6:37 nee,

  • @KrishnaMishra-fl6pu
    @KrishnaMishra-fl6pu 4 роки тому +42

    Not only you taught us how to make bind function but also u have taught us how to think...❤️ Loving your videos and hence loving js

  • @itspravas
    @itspravas 5 років тому +4

    i saw your video on bind, then i saw this one, paused it, tried to do this on my own, got sucess, i haven't used call or apply or any es6 ( like "..." notation )as you said its for older browsers, so yeah i did it, really happy with my result.

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

      Hi Pravas, can you please share your code, without es6, call and apply

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

      Would like to see the polyfill without call and apply, how do you pass the 'this' binding inside the returning function?

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

    Prototype ,proptotypal inheritence ,prototype chaining ,call bind apply all i have learnt from you now everything was implemented here and i understood it with utmost efficacy thanks Akshay

  • @sumitjangir48
    @sumitjangir48 5 років тому +8

    Bro.. You are doing social service for us... Thanks for your help.. Keep helping.. keep growing...

  • @akarshsrivastava8890
    @akarshsrivastava8890 4 роки тому +8

    I can clearly see closure application in poly filling the bind function. 😅 Thanks for providing this power to see through code, Akshay.

  • @raveenasharma4645
    @raveenasharma4645 3 роки тому +8

    Your explanation about basic concepts is so good. I've been watching the entire JS series! Thank you so much

  • @asitkumar8543
    @asitkumar8543 3 роки тому +7

    The bind() method creates a new function, when invoked, has the this sets to a provided value.
    The bind() method allows an object to borrow a method from another object without making a copy of that method. This is known as function borrowing in JavaScript.

  • @mdridoy-ef2pw
    @mdridoy-ef2pw 2 роки тому +1

    Not a even the og youtubers discuss these core topics like you.
    Thank you!
    More simpler version of the myBind function:
    Function.prototype.myBind = function (...args1) {
    return (...args2) => this.call(...args1, ...args2);
    }

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

    I never knew what polyfill was. It appeared to me as a advanced concept. But you have explained this topic very well and i think i have got a good grasp of it. THANKS A LOT.

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

    Hi @akshay, u r doing a great job !!
    i have one small suggestion.
    in line no 17 i think we can add return before obj.apply(....) also, because if printName will return something then our mybind will return always undefined.

  • @shadahmedmasthikund8965
    @shadahmedmasthikund8965 9 місяців тому

    The best teacher I've ever got for how to learn and what to learn in java script... Akshay sir❤

  • @mohityadav21
    @mohityadav21 3 роки тому +12

    Short solution:
    Function.prototype.mybind = function (...args) {
    return (...args2) => this.call(...args, ...args2);
    };
    "this" inside the arrow function refers to the function on which mybind function is called.

  • @learnmore9382
    @learnmore9382 5 років тому +13

    Explained very well. Please make a video on 'this'.

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

      after 5 yrs, ur wishes came true

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

    give this guy a medal...

  • @digvijaysingh9028
    @digvijaysingh9028 3 роки тому +8

    what a MASTERPIECE :)

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

    one thing we missed in this series. And that is your big smile.

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

    well explained... one thing I wanted to add if we add obj.call(...args) only then we don't need to do any other thing like param and apply... please try thanks !!!
    Function.prototype.mybind = function(...args) {
    let obj = this;
    return function (...args2){
    obj.call(...args, args2);
    }
    }
    let printName2 = fullName.mybind(name, 'Dehradun')
    printName2('Uttarakhand');

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

    Learned first time and wow it was super easy because of your teaching method. thanks bro

  • @shaikhshehroz2107
    @shaikhshehroz2107 5 років тому +3

    You are Best.. Very Well Explained.

  • @kirank3368
    @kirank3368 4 роки тому +4

    You are simply awesome 👏🏽 The way you clear things and make us understand it very straight is fabulousness. Thanks bro 🙏

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

    well explained 👍
    ------ updated code -------
    Function.prototype.myBind = function(obj, ...arg){
    const fn = this;
    return function(){
    fn.apply(obj, arg);
    }
    }

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

    you are the God of javascript bro love you

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

    Ultimate explanation Akshay! Really amazing work of helping so many like me out there. God bless you 🙏🏻
    "In the interviews, if we don't want to be SHY, then we gotta learn from AkSHAY" 😎

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

    Understanding it step by step- Awesome explaination

  • @priyankasingh-no1oz
    @priyankasingh-no1oz 3 роки тому

    Hi @Akshay, Thank you so much for making these videos. I saw your videos and cracked too many interviews for Front End Developer. Thank you so much again.

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

    You are a life saver for us man.......👍

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

    Awesome explanation. One minor thing is missing I believe which is returning the result of the bound function.
    return obj.apply(args[0], [...params, ...args2]);

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

    Wow this is one hell of an explanation.
    Love from Pakistan 🇵🇰

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

    It was kind of complicated but u nailed it easily 😃

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

    Hi Akshay,
    First of all you explain things really well, in a very simple and crisp manner. Please make a video on async await. This concept has always puzzled me and still not very confident about it. Please its a humble request.

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

    Very well explained Sir... your videos are great help for learning

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

    😍😍😍 Finally We wrote own Native code. Brendan Eich i'm coming 😝.

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

    Excellent explanation. Akshay bro u are fav teacher of mine..

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

    explained with simplicity. awesome content.

  • @aiknowledge-n2s
    @aiknowledge-n2s 2 роки тому +2

    Function.prototype.myBind = function (...args) {
    let ref = args[0];
    let params = args.slice(1);
    let obj = this;
    return function (...args2) {
    args[0].gt = obj; //This is my impelementation of the bind polyfill, I haven't used apply method over here.
    args[0].gt(...params, ...args2);
    };
    };
    //I have checked it works.

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

    Thanks I understand it completly.

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

    Your this playlist is just fire

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

    Thank You Akshay for this lovely explanation.

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

    Really impressive way of teaching and the topics/questions are superb.

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

    excellent work. great teaching . I love this. Thank you

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

    @Akshay Great explanation. Thank you. You are such a great teacher.😊

  • @rabahbabaci2342
    @rabahbabaci2342 5 років тому +3

    Thank you dude, this was an amazing explanation!
    Can you please make a video on how to implement the .call( ); method?

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

    I'm glad i found your channel, its gold. keep it up brother.

  • @jalluchakri1528
    @jalluchakri1528 3 місяці тому

    Hey ! Thanks for explaining its makes the comfort to learn any concept

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

    Thank you @Akshay explaining this complex topic in a such a easy way :)

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

    excellent example and teaching.

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

    Hi Akshay, If we use a Params directly in to the return function then we use obj.call(…args, …params)

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

    Great actually a Best video on UA-cam please make a JavaScript whole series

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

    Great content Akshay. Request you to make a video on arrow function and 'this' keyword in your Namaste JS series.

  • @vishalheble
    @vishalheble 4 роки тому +15

    When its a polyfill for a bind then can we really use apply or call ?

    • @patni1234561
      @patni1234561 3 роки тому +6

      This makes sense. As a interview question, it is okay, but what you said is valid. Which browser supports call apply but not bind.

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

    that was awesome. I am becoming your fan slowly. thank you for this valuable information.

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

    this is super awesome video for bind Polyfill . @akshay can you please create a polyfill video of Promise, call and apply method.

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

    Great Akshay. Awesome..
    Your explanation is very nice..

  • @shivrajnag12
    @shivrajnag12 4 роки тому +9

    So interviewers had figured it out how to torture Frontend guys with these questions since they don't expect DS and Algo from them. Good

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

      lol

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

      JS is not only about frontend bro.

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

      @@rhimanshu6288 polyfills are for browsers not node environment

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

    Well the video was great 🔥 thanks, but we are again using the apply and call function, can you do a video on how can we achieve it without using call() and apply(), thanks in advance.

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

    Really very good explanation

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

    pura hindi jaisa lagta h..nice

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

    Very nice explanation @Akshay Saini, "Ek number :-)"

  • @radhikamalpani2927
    @radhikamalpani2927 3 роки тому +6

    Please also start a playlist on Angular or React JS. I believe its going to help a lot of us. Thanks.

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

    Simple and Great Explanation Akshay :)

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

    Brilliant explanation

  • @vishalbisht6871
    @vishalbisht6871 5 років тому +4

    AWESOME !!!!

  • @thodupunurisaipriya3680
    @thodupunurisaipriya3680 Місяць тому

    Awesome teacher🎉

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

    You motivate me. Your teaching skills are fabulous. I learnt a lot by just viewing a few videos of yours 😊 Keep up the good work

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

    I have used here call method in place of apply method.
    And here is my code :
    let person={
    name :'John',
    age:30
    };
    let personDetails=function(city,street){
    console.log("Name : "+this.name+" Age : "+this.age+" City : "+city+" Street : "+street);
    }
    Function.prototype.mybind=function(...args){
    let obj=this,
    param=args.slice(1).toString();
    return function(...args2){
    param2=args2.toString();
    obj.call(args[0],param,param2)
    //obj.apply(args[0],[...param,...args2]);
    }
    }
    let result=personDetails.mybind(person,'Norway');
    result('11th Street');

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

      same for me call is also working for me

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

    Thanks for the explanation 😊

  • @doonssunshine3696
    @doonssunshine3696 5 років тому +9

    Fun will be when interviewer says apply is also not available write for that too

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

      You have a solution for that?

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

      @@vikramkrish710 yes

    • @deepak.chandola
      @deepak.chandola 4 роки тому

      @@vikramkrish710 use call with array spread

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

      @@vikramkrish710 Something like this...
      Function.prototype.myBind1 = function (...args) {
      let obj = this;
      let params = args.slice(1);
      return function (...args1) {
      obj.call(args[0], [...new Set(params)], [...new Set(args1)]);
      };
      };

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

      @@venkateshdec27 explain ...new Set pls.

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

    O bhayankar, dehradun se. 😂😂 great tutorial

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

    concept explained very clearly. Thanks :) , gotta learn alot from you

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

    Good explaination bro ..... keep it up ! 👌

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

    It was really good! Please post videos on promises!

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

    Thanks for the beautiful explanation...
    @everyone :any suggestions on angular 9 learning video please

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

    you got subscriber++. thank you Akshay the video is awesome

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

    Good one akshay, Jhakkas

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

    Thanks Akshay for explaining it clearly. I think this is the best video I watched on polyfils. I have a small question here, when we are trying to console this inside Function.prototype.myBind it is referring to window and at the same time if we assign it to variable it is referring to binding function printFullName. is this normal behaviour or am I reading it wrong?

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

    Simply Awesome.

  • @Enjoyment1991
    @Enjoyment1991 5 років тому +4

    Hi akshay, your teaching skills are exceptional! and can you make a video series on css? you have covered core and advanced concept of javascript likewise I need in css with building a web application from scratch

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

    Awesome as always

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

    You are like the Yoda of bind method. :-D

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

    Wao

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

    @akshay Saini Thanks for this answer. Could you add video for implementing Two way data binding .

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

    Bro you are so pro.....

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

    We should also understand this code will not work as a real polyfill because bind fn is a es5 contruct and “...” is a es6 construct. We should use arguments object to access the args.

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

    Nicely explained. Just wondering if interviewer will be okay with a polyfil for bind that uses apply internally. I mean call, bind and apply fall into a common category. Also, a browser that supports ES6 spread operator would also support bind.

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

    @Akshay, that was a great explanation, Could you please bring such explanation for Polyfill for promise?

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

      Yup, that's a great ask. Thank you, I'll try to come up with it soon. ❤️

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

    Outstanding bro . Can you please make a video on polyfill for promises

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

    Thanks for the video

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

    Hi, Can you also make a video on implementing own promise and implementing own virtual DOM ? @akshay please make on async and await concepts as well.....waiting for it

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

    Awesome work man! keep it up! really helped me through. :)

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

    Wow 😍

  • @RavindraSingh-zg9eq
    @RavindraSingh-zg9eq Рік тому

    nice great helpful

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

    sir please also make video for call and apply method

  • @paras981
    @paras981 4 роки тому +4

    Thank you so much for creating this video! This really helped all of us a lot! #AkshayMeraBhai

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

    your explanations are simple and clear. btw, is this black t-shirt your recording uniform?

  • @IshaSoni-o5e
    @IshaSoni-o5e Місяць тому

    instead of use apply method and other lengthy code can simple optimize the code by using return function(){
    obj.call(...args)
    }

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

    Thanks sir❣️❣️❣️

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

    Great video man !!