diff --git a/snippets/defer.md b/snippets/defer.md index 88706b86d..1a0a63649 100644 --- a/snippets/defer.md +++ b/snippets/defer.md @@ -2,7 +2,7 @@ Defers invoking a function until the current call stack has cleared. -Use `window.setTimeout()` with a timeout of 1ms to add a new event to the browser +Use `setTimeout()` with a timeout of 1ms to add a new event to the browser event queue and allow the rendering engine to complete its work. Use the spread/rest (`...`) operator to supply the function with an arbitrary number of arguments. @@ -16,6 +16,6 @@ defer(console.log, 'a'), console.log('b'); // logs 'b' then 'a' // Example B: document.querySelector('#someElement').innerHTML = 'Hello'; -longRunningFunction(); // The browser will not update the HTML until this has finished -defer(longRunningFunction); // The browser will update the HTML then run the function +longRunningFunction(); // the browser will not update the HTML until this has finished +defer(longRunningFunction); // the browser will update the HTML then run the function ```