Logo

Programming-Idioms

History of Idiom 185 > diff from v15 to v16

Edit summary for version 16 by kickass:
[JS] some platforms don't have window object, dude

Version 15

2019-09-27, 07:13:42

Version 16

2019-09-27, 07:37:49

Idiom #185 Execute function in 30 seconds

Schedule the execution of f(42) in 30 seconds.

Idiom #185 Execute function in 30 seconds

Schedule the execution of f(42) in 30 seconds.

Extra Keywords
future
Extra Keywords
future
Code
let id = window.setTimeout(f, 30000, 42);
Code
let id = setTimeout(f, 30000, 42);
Comments bubble
The second arg is the delay in milliseconds.

The subsequent args will be passed to the function f.

id identifies the timer created by setTimeout, and can be used to cancel the timeout.
Comments bubble
The second arg is the delay in milliseconds.

The subsequent args will be passed to the function f.

id identifies the timer created by setTimeout, and can be used to cancel the timeout.
Doc URL
https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout
Doc URL
https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout
Demo URL
https://codepen.io/val_deleplace/pen/gOYvZaG?editors=1111
Demo URL
https://codepen.io/val_deleplace/pen/gOYvZaG?editors=1111