JSFiddle - React, Tailwind, and code Playground

by ExplosionPIlls

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);