JavaScript does not support threading with shared memory. As an alternative, browsers support delayed execution via timer events. This means that all code is executed in sequence in the same browser thread that handles HTML events, etc.
setTimeout(() => print('working...'), 500);
var handle = setInterval(() => print('repeating...'), 1000)
setTimeout(() => { clearInterval(handle); print('cleared'); }, 3100);
handle
2
setTimeout(() => print('immediate'), 0);
function callLater(millis, func, ...args) { setTimeout(func.bind(null, ...args), millis); } callLater(123, print, 'one', 2, 'three')
The console allows you to interact with the course material and examples. Use the following keys:
A special logging function is also available: