Skip to main content
showmecode.chanx.app

写一次,跑过边界,再提交。

给前端工程师的编程题练习场。先从防抖和节流开始,在可见用例里验证每一次选择,把真正的边界留给隐藏测试。

02
题目数量
JS
运行语言
D1 + R2
数据边界
debounce.js
playground
1
2
3
4
5
6
7
8
9
10
11
12
function debounce(fn, delay) {
 let timer;
  return function (...args) {
    clearTimeout(timer);
    timer = setTimeout(() => {
      fn.apply(this, args);
    }, delay);
  };
}

2 visible tests · 4 hidden tests
✓ visible / trailing-call
最后一次调用的参数应该被保留 运行通过