[모던 자바스크립트 Deep Dive] 45장 Promise
·
Frontend/Study
45장 Promise 1. 비동기 처리를 위한 콜백 패턴의 단점1) 콜백 헬어떠한 함수를 실행했을 때, 해당 함수 내부의 비동기 함수가 완료되지 않았다해도, 비동기 함수를 기다리지 않고 즉시 종료 된다. ex) setTimeout 비동기 함수let g = 0;setTimeout(() => { g = 100; }, 0);console.log(g); // 0 ex) get요청 비동기 함수const get = url => { const xhr = new XMLHttpRequest(); xhr.open('GET', url); xhr.send(); xhr.onload = () => { return JSON.parse(xhr.response); }};const res = get('https://..