setTimeout() vs clearTimeout()
setTimeout() and clearTimeout() are both JavaScript Global APIs, and choosing between them is a common point of confusion. This page compares their syntax, parameters, return values, and typical use cases so you can pick the right one. setTimeout(): Executes a function after a delay (ms). Its syntax is setTimeout(callback, delay, ...args). clearTimeout(): Cancels a timeout. Its syntax is clearTimeout(timeoutId). Example of setTimeout(): setTimeout(() => console.log("Done"), 1000). Example of clearTimeout(): const t = setTimeout(() => {}, 1000); clearTimeout(t). Read the full references for setTimeout() and clearTimeout() to see edge cases, time complexity, browser support, and the mistakes developers most often make with each. Other Global APIs worth comparing: setInterval(), clearInterval(), setImmediate(), queueMicrotask(), fetch(), eval(). Both belong to the Global category in the JS Reference documentation, which covers 49 entries in total. Try both in the JavaScript playground to see the behavioral difference live.