7 ms·
Here's an example which might explain the decoupling a bit: // You may call this syntactic sugar var p1 = new Promise(function(response, reject) {
by y1426i 13y ago
Here's an example which might explain the decoupling a bit:
// You may call this syntactic sugar
var p1 = new Promise(function(response, reject) {
setTimeout(function(){
response(Math.random() * 1000);
});
}).then(function(val){ console.log(val); return val; });
// But here's the magical decoupled call
p1.then(function(val) { console.log(val); });