2020.11.11 [TIL] Promise (feat.영원한 사랑)
2021. 3. 20. 22:55ㆍWannabe IT Geek/Javascript
반응형
1. Promise 란?
Promise란 향후에 언젠가 사용하게 될 값을 생산해내는 객체, 자바스크립트 비동기 처리에 사용됨.
2. Promise의 세 가지 상태
- Pending : neither fulfilled nor rejected.
- Fulfilled : meaning that the operation was completed successfully.
- Rejected : meaning that the operation failed.
3. promise.prototype의 메소드
- promise.prototype.catch
=> 프로미스(promise)에 거부 처리기 콜백을 추가하고 호출된 경우 콜백의 반환값 또는 프로미스가 대신 이행된 경우 그 원래 이행(fulfillment)값으로 결정하는(resolving) 새 프로미스를 반환합니다. - promise.prototype.then
=>프로미스에 이행 또는 거부 처리기를 추가하고 호출된 처리기의 반환값 또는 프로미스가 처리되지 않은 경우 그 원래 처리된(settled) 값으로 결정하는 새 프로미스를 반환합니다 (즉 관련 처리기 onFulfilled 또는 onRejected가 undefined인 경우).
- promise.prototype.finally
=> Appends a handler to the promise, and returns a new promise which is resolved when the original promise is resolved. The handler is called when the promise is settled, whether fulfilled or rejected.
반응형
'Wannabe IT Geek > Javascript' 카테고리의 다른 글
2020.11.15 [TIL] CORS (0) | 2021.03.20 |
---|---|
2020.11.13 [TIL] Client, AJAX, HTTP, API, server, 이게 다 뭐람! (0) | 2021.03.20 |
2020.11.08 [TIL] 나를 힘들게 하는 재귀, Recursion (0) | 2021.03.20 |
2020.11.07 [TIL] Call, Apply, Bind (0) | 2021.03.20 |
2020.11.07 [TIL] This, 디스? 디스! (0) | 2021.03.20 |