Why does js imitate jitter function save this and bind scope for callback when executing

RT because the this pointer in the anonymous function already points to window. I don"t understand what it means if you just want to pass the args parameter list through apply as fn.apply (window, args);.

fn.apply (context, args);


  let timer = null;

  return function() {
    
    let context = this;
    let args = arguments;

    clearTimeout(timer);
    timer = setTimeout(function() {
      fn.apply(context, args);
    }, delay);
  }
} 



Mar.01,2021

this article is very good. I recommend

The this in the

timer points to window,. I suggest you check that the js's this points to


setTimeout. The this in the function points to window. If you need to access the context of function in fn, you need to pass it. Otherwise, it is possible not to pass


the this in the throttled function may not be window


. It is impossible to know the this of the anonymous function from your function definition, depending on how the anonymous function is called.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31b44-2bdc3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31b44-2bdc3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?