按顺序执行多个异步函数的方法

function a(cb){
	console.log('this is a1 ')
	cb()
	console.log('this is a2')
}
function b(cb){
	console.log('this is b1')
	cb('b')
	console.log('this is b2')
}
function c(cb){
	console.log('this is c1')
	cb()
	console.log('this is c2')
}
function d(cb){
	console.log('this is d1')
	cb()
	console.log('this is d2')
}
function e(cb){
	console.log('this is e1')
	cb()
	console.log('this is e2')
}
function f(){
	console.log('this is f')
}
a(b.bind(null,c.bind(null,d.bind(null,e.bind(null,f)))))



 
  

this is a1 

this is b1

this is c1

this is d1

this is e1

this is f

this is e2

this is d2

this is c2

this is b2

this is a2

改变console.log与cb的位置还可以得到不同的结果,具体可以多实验

你可能感兴趣的:(按顺序执行多个异步函数的方法)