JSFiddle - React, Tailwind, and code Playground
JavaScript
function closure_count_test (number)
{
for (var x = 0; x <= number; x += 1)
{
setTimeout(
(function (x) {
return function () { console.log(number - x) };
})(x)
, x * 1000);
}
}
closure_count_test(3);