Promise.resolve()
Returns a promise that is resolved with the given value.
Syntax
Promise.resolve(value)
Returns
Promise — A promise resolved with `value`; if `value` is a thenable, it adopts
its state.
Examples
Promise.resolve(42).then(v => console.log(v));
Output
42
const p = Promise.resolve("x");
console.log(Promise.resolve(p) === p);
Output
true
Promise.resolve(Promise.resolve("nested"))
.then(v => console.log(v));
Output
nested
Notes
- If passed an existing promise, it returns that same promise.
- If passed a thenable, the result follows that thenable.
- Useful for normalizing values into promises.
Browser & runtime support
| Environment | Since version |
|---|---|
| chrome | 32 |
| firefox | 29 |
| safari | 8 |
| edge | 12 |
| node | 0.12 |