'use strict'엄격 모드를 설정합니다.
const promise = new Promise((resolve, reject) => {
console.log('doing something...');
});주의 : Promise는 자동으로 실행됩니다.
const promise = new Promise((resolve, reject) => {
console.log('doing something...');
setTimeout(() => {
resolve('hello');
}, 2000);
});
promise
.then(value => {
console.log(value);
})
.catch(error => {
console.log(error);
});
.finally(() => {
console.log('finally');
});이때는 then, catch, finally 를 사용할 수 있습니다.