Promise.reject()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Promise.reject(reason)
메서드는 주어진 이유(reason)로 거부된 Promise
객체를 반환합니다.
구문
js
Promise.reject(reason);
매개변수
- reason
-
이
Promise
를 거부한 이유.
설명
정적 Promise.reject
함수는 거부된 Promise
를 반환합니다. 디버깅 목적 및 까다로운 오류를 잡기 위해, reason
을 Error
생성자의 인스턴스로 만들면 유용합니다.
예
정적 Promise.reject() 메서드 사용
js
Promise.reject("Testing static reject").then(
function (reason) {
// 호출되지 않음
},
function (reason) {
console.log(reason); // "Testing static reject"
},
);
Promise.reject(new Error("fail")).then(
function (error) {
// 호출되지 않음
},
function (error) {
console.log(error); // Stacktrace
},
);
명세서
Specification |
---|
ECMAScript® 2025 Language Specification # sec-promise.reject |
브라우저 호환성
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
reject() |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.