Using setTimeout to update progress bar when looping over multiple variables

后端 未结 4 1475
死守一世寂寞
死守一世寂寞 2020-12-20 01:04

Suppose you have 3 arrays you want to loop over, with lengths x, y, and z, and for each loop, you want to update a progress bar. For example:

function run()         


        
4条回答
  •  鱼传尺愫
    2020-12-20 01:25

    If you want to use setTimeout you could capture the x, y, z and count variables into a closure:

    function run() {
        var x = 100,
            y = 100,
            z = 10,
            count = 0;
        for (var i=0; i

    Live demo.

提交回复
热议问题