HomeToolsAbout

Map/Looping Promise

What is it

const mapPromise = (array) => { const promises = array.map(async (val) => { return { r_val: await service.getByValue(val) } }); return Promise.all(promises); }

continue and break

continue

Skip current round in looping and jump to the next round.

for (let i = 0; i < 10; i++) { if (i === 3) { continue; } console.log(i); } // 0,1,2,4,5,6,7,8,9 // skips 3

break

Terminates the loop (not just current iteration) when reached.

for (let i = 0; i < 10; i++) { if (i === 3) { break; } console.log(i); } // 0,1,2 // stops iterating at 3
AboutContact