Sobes.tech
Junior — Senior
42

Печать переменной c с учётом всплытия и тайм‑аута

Companies where asked:

SmartWay
Task condition

В функции выводятся значения переменной c в разных точках выполнения, демонстрируя поведение всплытия (hoisting) и работу асинхронного 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()