let a = new Promise((resolve,reject)=>{ resolve() }) a.then(res=>{ console.log('a') a.then(res=>{ console.log('c') }) }) a.then(res=>{ console.log('b') }) function add(getX,getY,cb){ console.log(getX) let x,y getX(function(xValue){ x = xValue if(y != undefined){ db(x+y) } }) getY(function(yValue){ y = yValue if(x != undefined){ db(x+y) } }) } let d = function(item){ } let b = function(item){ } add(d,b,function(sum){ console.log(sum) })