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

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的位置还可以得到不同的结果,具体可以多实验

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值