Skip to main content
100%

settimeout-example.js

✓ Published0🌍 Public
Aalessioalex
Last edited Nov 22, 2014
Created on Nov 22, 2014

This example demonstrates the use of `setTimeout` to schedule repeated asynchronous callbacks in JavaScript. It defines a `tellMeLater` function that loops ten times, invoking `setTimeout` with `log.bind(null, i)` to log each index after a 100-millisecond delay. The `log` function writes its argument to the console via `console.log`. The code shows how `Function.prototype.bind` creates a fixed argument for each scheduled call, ensuring the loop variable’s value is captured correctly despite the asynchronous execution.

AI-generated description

Similar vizzes