jeudi 13 mai 2021

Arrow functions with call/apply/bind

MDN website states that call, bind and apply should not be used with arrow functions. Makes sense since they take the context of the parent from the place they are defined and use that itself.

Now this is the code for debounce I have seen in a few videos. Does using apply even do something here?

const getData = () =>

{

}

const debounce = function (fn, d) { let timer; return function () {

let context = this,

  args = arguments;

clearTimeout(timer);

timer = setTimeout(() => {

  getData.apply(context, arguments);
}, d);
} }

Aucun commentaire:

Enregistrer un commentaire