//程序运行完成时一定要有输出语句,本工具才能正确展示运行结果。
console.log("Hello JSRUN! \n\n - from NodeJS .");
async function doAsyncTask(value){
return new Promise((resolve, reject)=>{
setTimeout(()=>{
console.log(Date.now())
resolve(value)
}, 2000)
})
}
// [1,2,3].forEach(async item=>{
// console.log('callback:', item)
// await doAsyncTask(item)
// })
// async function asyncForEach(array, callback) {
// for (let index = 0; index < array.length; index++) {
// await callback(array[index], index, array);
// }
// }
// asyncForEach([1,2,3], async (item)=>{
// console.log('callback', item)
// await doAsyncTask(item)
// })
// [1,2,3].reduce(async (prev, item,index)=>{
// console.log('callback', item)
// await doAsyncTask(item)
// }, null)
(async ()=>{
var arr=[1,2,3]
for(let index; index<arr.length; index++){
console.log('callback', arr[index])
// await doAsyncTask(arr[index])
}
})()