let a, b; a = [10, 20, 30, 40];1b = a.map(async n => await n / 10); console.log(b); //Map gives us promises:2//[ Promise { 1 }, Promise { 2 }, Promise { 3 }, Promise { 4 } ] //Resolve promises3b = await Promise.all(b); console.log(b); //Now we have proper objects4//[ 1, 2, 3, 4 ]
let a, promise; a = [10, 20, 30, 40];1promise = a.reduce(async (accum, each) => await (accum + each)); console.log(promise); //Map gives us promises:2//Promise { <pending> } let resolvedValue;3resolvedValue = await promise; console.log(resolvedValue); //Map gives us promises:4//[object Promise]40