⊗jsSpPrmPICh 168 of 294 menu

Promises within a chain in JavaScript

Functions within a chain can also return promises. In this case, the result of this promise will fall into the next then:

promise.then( function(result) { return result + '1'; } ).then( function(result) { return new Promise(function(resolve) { resolve(result + '2'); // this result will fall into the next then }); } ).then( function(result) { return result + '3'; } ).then( function(result) { console.log(result); // shows 'string123' } );
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline