선생님 promise 스코프에 대해 질문 있습니다.
promise.resolve() 예시를 찾아보다가, resolve 가 다음 .then()으로 제대로 넘어가지지 않는 예시를 공부했는데요.
promise.resolve().then()의 .Then() 안에 promise.resolve () 가 있는데 이 부분이 실행이 완료되기 전에 다음 .then()으로 넘어가서 promise.resolve() 값이 다음 .then()에 제대로 안받아지므로, promise.resolve().then()을 사용하지 말고, new Promsie를 써야 한다는 내용입니다.


그런데 제가 이해가 안가는 점은...
1.
promise.resolve().then() 의 then() 안에서 promise.resolve() 를 리턴하는 코드나,
new Promise() 안에 있는 resolve()를 리턴하는 코드나,
promise.resolve() 의 블록 스코프 또는 new Promise() 블록 스코프에서 resolve를 직접적으로 리턴받지 않고,
xhr.onreadystatechange = function () { } 블록 안에서 resolve 를 만들고,
xhr.onreadystatechange 에 할당되어 있을 뿐입니다.
이러면 resolve는 promise.resolve().then() 안이나 new Promise() 안에서 받아지는 것이 아니고,
xhr.onreadystatechange 에 할당되어질 뿐이고,
생성된 resolve()는 xhr.onreadystatechange 스코프 안에서만 유효한건데,
어떻게 다음에 이어지는 .then()에 resolve 값이 전달될까요??
2.
또 promise.resolve().then() 의 .then() 안의 코드 xhr.onreadystatechange = function ~ 가 아직 다 실행 안됬는데, 왜 다음 .then()으로 넘어갈까요??