Instantiate a resolved promise in ES2015

2020-04-01 08:36发布

问题:

What is the canonical way to create a resolved promise in ES 2015?

回答1:

The Promise.resolve class method returns a promise that is instantiated as resolved with a value you can specify:

var promise = Promise.resolve(100);