function Main(callAsync) {
if (callAsync) AsyncFunc();
NextFunc();
}
function AsyncFunc(next) {
setTimeout(function() {
console.log('async!');
if (next) next();
}, 1000);
}
function NextFunc() {console.log('Next');}

콜백지옥 진짜 도망가고싶다 ㅠㅠ


의도하는건 순차적으로 실행되었으면해. aync 다음 next가 나오게끔.


콜백 없이 하는방법 없을까??


어떻게 검색해야 할지도 모르겠고 ㅠㅠ 돌겠어 진짜 ㅠㅠ



이럴때마다 콜백을 만드니까

function Main(callAsync) {
if (callAsync) AsyncFunc(function() {NextFunc()});
else NextFunc();
}

죄다 이런 형태가 되는게 너무 싫어서말이야.


꽃간지 형들 저에게 가르침을 ㅠㅠ