Webcourse/13-前端面试/02-面试题积累/异步.md
2020-04-19 18:24:43 +08:00

452 B
Raw Blame History

面试题

20180321面试题

    console.log(1);

    setTimeout(function () {
        console.log(2);
    }, 1000);

    setTimeout(function () {
        console.log(3);
    }, 0);

    console.log(4);

20180321面试题

    var arr = [1, 2, 3];
    for (var i = 0; i < arr.length; i++) {
        setTimeout(function () {
            console.log(i);
        }, 0);
    }

打印结果333