# JS Tip of the Day: setTimeout Callback Arguments

**URL:** https://forum.kirupa.com/t/js-tip-of-the-day-settimeout-callback-arguments/643151
**Category:** web dev
**Created:** [March 16, 2020, 2:24pm UTC](https://forum.kirupa.com/t/js-tip-of-the-day-settimeout-callback-arguments/643151 "2020-03-16T14:24:48Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)
#### Post date: [March 16, 2020, 2:24pm UTC](https://forum.kirupa.com/t/js-tip-of-the-day-settimeout-callback-arguments/643151/1 "2020-03-16T14:24:48Z")

</div>

**setTimeout Callback Arguments**  
Level: Beginner

The `setTimeout` function lets you delay the call of a callback function by a specified number of milliseconds.

```javascript
function afterAWhile () {
    console.log('after a while, crocodile');
}

setTimeout(afterAWhile, 2000);
console.log('later, alligator'); 
/* logs:
later alligator
(waits 2 seconds)
after a while, crocodile
*/

```

As with most callbacks, since you are not in direct control of calling the callback function, you do not necessarily decide how the function is called or with what arguments. However, in the case of `setTimeout` (and `setInterval`), it does let you specify the arguments its callback gets called with. Any arguments you provide to after the millisecond (delay) argument will be automatically forwarded to the callback when it’s ultimately called.

```javascript
function afterAWhile (whom) {
    console.log('after a while, ' + whom);
}

setTimeout(afterAWhile, 2000, 'crocodile');
console.log('later, alligator'); 
/* logs:
later alligator
(waits 2 seconds)
after a while, crocodile
*/

```

More info:

- [setTimeout on MDN](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout)
- [setInterval on MDN](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval)
