Skip to content
Junior–Senior167 views

Printing variable c considering bubbling and timeout

Asked at

Task condition

The function outputs the values of the variable c at different points during execution, demonstrating the behavior of hoisting and the operation of the asynchronous setTimeout.

function l() {
    console.log(c);
    var c = 5;
    setTimeout(function() {
        console.log(c);
        var c = 10;
        console.log(c);
    }, 100);
    console.log(c);
};

l()
Frontend tasks in the code trainer