Engrain by ByteRush

JS.14.06 Mid-level

sleep, timeout, and setInterval via setTimeout

Comes up in: Coding

This concept is being written. It gets the full five steps — explanation, predict, interview angle, practice with tests, and review cards. Here is exactly what it will cover, so you can study it elsewhere in the meantime.

What it covers

  • abortable sleep
  • withTimeout(promise, ms)
  • drift-corrected interval
  • mySetInterval/myClearInterval

Words you will know

timer drift

What you will practise

  • implement with fake timers in tests

Interview questions this answers

  • Implement sleep that can be aborted.
  • Implement setInterval using setTimeout.