The reject() method of the Promise object takes a value and returns a rejected Promise object with the passed value as the reason. Unlike the Promise.resolve() method, the reject() method is used for debugging purposes and not for converting values into promises.
Here is an example that demonstrates how to use the reject() method:
const p1 = Promise.reject(4);p1.then(null, function(value){console.log(value);});Promise.reject({name: "Eden"}).then(null, function(value){console.log(value.name);});
The output is as follows:
4Eden