A promise is an object which is responsible for making a promise in a callback function with 2 possible states, it either resolves or rejects.
The promise.reject() method is used to return a rejected Promise object with a given reason for rejection. It is used for debugging purposes and selective error catching. The catch() method can be used for logging the output of the reject() method to the console.
Parameter: This method accepts a single parameter as mentioned above and described below:
- reason: It is the reason for which the promise is rejected.
Return value: It returns the rejected promise with the given reason.
The examples below illustrate the reject() method:
rejected the promise, something wrong happened
Not greater than 100