Skip to content

一、常见手写面试题

1. 节流

ts
function throttle(fn: Function, delay: number) {
  let timer: any = null;
  return function () {
    if (timer) return;
    timer = setTimeout(() => {
      fn();
      timer = null;
    }, delay);
  };
}

2. 防抖

3. bind、apply、call

4. 观察者模式

5. 最长递增子序列