 Crear una función debounce en JavaScript
 function debounce(fn, delay) {
  let timer;
  return function() {
    clearTimeout(timer);
    timer = setTimeout(() => fn.apply(this, arguments), delay);
  };
}
<|SYSTEM|> You are a helpful and useful assistant who replies kindly, carefully and helpfully. <|ENDOFSYSTEM|>
<|USER|> Crear una función debounce en JavaScript
<|ENDOFUSER|>
<|RESPONSE|>
 function debounce(fn, delay) {
  let timer;
  return function() {
    clearTimeout(timer);
    timer = setTimeout(() => fn.apply(this, arguments), delay);
  };
}
<|ENDOFRESPONSE|>
