new Promise(res=>res('result'))
.then(val=>{results.push('then ' + val); return'first then rval';})
.then(val=>results.push('chained then with val: ' + val));
new Promise((res, rej)=>rej('rejection'))
.catch(val=>{results.push('catch ' + val); return results.length;})
.then(val=>results.push('then after catch with val: ' + val),
val=>{thrownew Error("mustn't be called")});
new Promise((res, rej)=> {res('result'); rej('rejection'); })
.catch(val=>{thrownew Error("mustn't be called");})
.then(val=>results.push('then after resolve+reject with val: ' + val),
val=>{thrownew Error("mustn't be called")});
new Promise((res, rej)=> { rej('rejection'); res('result'); })
.catch(val=>{results.push('catch after reject+resolve with val: ' + val);})
drainJobQueue();
assertEq(results.length, 6);
assertEq(results[0], 'then result');
assertEq(results[1], 'catch rejection');
assertEq(results[2], 'catch after reject+resolve with val: rejection');
assertEq(results[3], 'chained then with val: first then rval');
assertEq(results[4], 'then after catch with val: 2');
assertEq(results[5], 'then after resolve+reject with val: result');
results = [];
Promise.resolve('resolution').then(res=>results.push(res),
rej=>{ thrownew Error("mustn't be called"); });
let thenCalled = false;
Promise.reject('rejection').then(_=>{thenCalled = true},
rej=>results.push(rej));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.