mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
30 lines
649 B
JavaScript
30 lines
649 B
JavaScript
var p = new Promise(function(res,rej) {
|
|
setTimeout(res, 10, "Hello");
|
|
}).then(function(r) {
|
|
console.log("resolve ",r);
|
|
});
|
|
|
|
|
|
// Check that promises work even if the function is called immediately
|
|
var p = new Promise(function(res,rej) {
|
|
rej("Hello");
|
|
}).catch(function(r) {
|
|
console.log("reject", r);
|
|
});
|
|
|
|
var p = new Promise(function(res,rej) {
|
|
setTimeout(res, 10, "Hello");
|
|
}).then(function(r) {
|
|
console.log("resolve ",r);
|
|
});
|
|
|
|
var p = new Promise(function(res,rej) {
|
|
setTimeout(res, 10, "Hello");
|
|
}).then(function(r) {
|
|
console.log("resolve 1",r);
|
|
}).then(function(r) {
|
|
console.log("resolve 2",r);
|
|
});
|
|
|
|
trace(p);
|