JavaScript · Senior · Question 64 of 75

Why do schedulers (e.g. React's) use MessageChannel instead of setTimeout(fn, 0)?

Explanation

Nested setTimeout calls are clamped to at least 4ms by the HTML spec. A message event yields to the browser for rendering and input, then continues quickly.

Further reading

Problem with a question

JavaScript · Senior · question 64

Test yourself

Take the JavaScript · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz