var original = Promise.resolve(33);
original.then( val => console.log('origianl', val);
var cast = Promise.resolve(original);
cast.then(function(value) {
console.log('value: ' + value);
});
console.log('original === cast ? ' + (original === cast));
// logs, in order:
// original === cast ? true
// value: 33
Promise.resolve(value);
// Using the static Promise.resolve method
Promise.resolve('Success').then(function(value) {
console.log(value); // "Success"
}, function(value) {
// not called
});
// Resolving an array
const p = Promise.resolve([1,2,3]);
p.then(function(v) {
console.log(v[0]); // 1
});
// Resolving thenables and throwing Errors
const p2 = Promise.resolve(thenable);
p2.then(function(v) {
// not called
}, function(e) {
console.error(e); // TypeError: Throwing
});