목록Asynchronous (2)
코딩쌀롱

마이크로 태스크, 매크로 태스크, PromiseJobs 얘네들이 도대체 뭔가..했는데 이제 좀 알 것 같다. 기쁘다!🤪 ✱ 용어 정리 용어 정리를 하자면, 매크로 태스크 큐는 이벤트 루프를 설명할 때 나오는 태스크 큐(콜백 큐)와 같다. 그리고 PromiseJobs큐는 마이크로 태스크 큐와 같고, PromiseJobs큐는 ECMA, 마이크로 태스크 큐는 V8엔진에서 부르는 이름만 다른 것이다. 매크로 태스크 큐 = 태스크 큐 = 콜백 큐 마이크로 태스크 큐 (V8) = PromiseJobs 큐 (ECMA) ✱ 마이크로 태스크 큐, 매크로 태스크 큐 이벤트 루프의 동작 원리에 대해서 공부할 때 아래와 같은 자료들을 자주 보게 되는데, 이 때 콜백 큐(태스크 큐)는 하나의 큐처럼 보이지만 실제로는 여러 개의..
✏️비동기(Asynchronous) 📌 예시 이해하기 ✱1번 function test() { let result = null; fetch('https://jsonplaceholder.typicode.com/todos/1') .then(response => response.json()) .then(json => result = json) return result; } test(); // null 서버와 통신(fetch)하는 일은 브라우저가 하는 일이니까 브라우저에게 보내고 다음 코드를 실행. 그래서 result에 원래 담겨져있던 null 반환. function test() { fetch('https://jsonplaceholder.typicode.com/todos/1') .then(response => r..