Today will feel the async vibes! ⏰ with custom timer implementation
Question
Implement polyfill function that simulates the setTimeout
using callbacks.
window.mySetTimeout = function(callback, delay) { // Todo add your code }; function delayedFunction() { console.log("Delayed function executed"); } console.log("Start"); mySetTimeout(delayedFunction, 1000); // Delayed function will be called after approximately 1000ms console.log("End");
NOTE: 🤔 Attempting epic advanced-level question. Failure? Nah, fun exploration! Feel the process!😂
Check the comment below to feel more. 🤣🤣🤣
Top comments (3)
Hope this magic helps
where's requestIdCallback definition
requestIdCallback
taken from window or global object.MDN: The
window.requestIdleCallback()
method queues a function to be called during a browser's idle periods.