[TIL] Promise (feat.영원한 사랑)

ytwicey·2020년 11월 11일
0

TIL

목록 보기
11/23
post-thumbnail

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의 메소드

  1. promise.prototype.catch
    => 프로미스(promise)에 거부 처리기 콜백을 추가하고 호출된 경우 콜백의 반환값 또는 프로미스가 대신 이행된 경우 그 원래 이행(fulfillment)값으로 결정하는(resolving) 새 프로미스를 반환합니다.

  2. promise.prototype.then
    =>프로미스에 이행 또는 거부 처리기를 추가하고 호출된 처리기의 반환값 또는 프로미스가 처리되지 않은 경우 그 원래 처리된(settled) 값으로 결정하는 새 프로미스를 반환합니다 (즉 관련 처리기 onFulfilled 또는 onRejected가 undefined인 경우).

  3. 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.

profile
always 2B#

0개의 댓글