promise의 이해1
promise의 이해1
func1()
.then(func2)
.then(func3)
.then(func4)
.then(func5)
.then(func6)
.then(func7);
function func1(){
return new Promise((resolve, reject)=>{
console.log('func1실행');
setTimeout(resolve, 2000)
})
}
function func2(){
return new Promise((resolve, reject)=>{
console.log('func2실행');
setTimeout(resolve, 2000)
})
}
function func3(){
return new Promise((resolve, reject)=>{
console.log('func3실행');
setTimeout(resolve, 2000)
})
}
function func4(){
console.log('func4실행');
}
function func5(){
console.log('func5실행');
}
function func6(){
return new Promise((resolve, reject)=>{
console.log('func6-1실행');
//setTimeout(resolve, 2000);
func6_1().then(()=>{
resolve();
})
})
}
function func7(){
console.log('func7실행');
}
function func6_1(){
return new Promise((resolve, reject)=>{
setTimeout(()=>{
console.log('func6_1실행');
resolve();
}, 2000)
})
}
댓글
댓글 쓰기