javascript - How to implement the following flow control scheme
巴扎黑
巴扎黑 2017-05-31 10:41:05
0
2
638

巴扎黑
巴扎黑

reply all(2)
曾经蜡笔没有小新

I was very touched by this code, so I typed GG. You can directly enter the following code in the console to see the result. . .

function async(arr){
    if( Object.prototype.toString.call(arr) != "[object Array]" ){
        return false;
    }
    var target = arr.shift();
    if(typeof target != "function"){
        return false;
    }
    target(function(){
        async(arr);
    });
}

var one = function(callback){
    setTimeout(function(){
        console.log("first");
        callback();
    },200);
};

var two = function(callback){
    setTimeout(function(){
        console.log("second");
        callback();
    },100);
};

async([one,two]);
async([one,two,two,one,two]);
漂亮男人

I really want to ask, there must be a url for asynchronous use. You can write the url as a function. . .

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template