topic description
two asynchronous functions are required to write a function that asyncOneByOne (arr) can sequentially execute input parameters
asyncOneByOne([one, two])
//
//first
//second
function one(callback) {
setTimeout(function () {
console.log("first");
callback && callback();
}, 200);
}
function two(callback) {
setTimeout(function () {
console.log("second");
callback && callback();
}, 0);
}
sources of topics and their own ideas
A written test question, at first I thought I would use promise or something, but one () two () didn"t let me change
, and then I found that as long as
one (two (one (two)
, I could execute it (read the callback function chapter)
what result do you expect? What is the error message actually seen?
so the problem becomes the problem of entering an array [one, two, one, two], how to change it into one (two (one (two) and how to execute it, but here it has been pasted out. Let me ask you how to deal with it.