js

梗概

示例

const arr = [1, 2, 3];
const asyncMap = async () => {
  const results = await Promise.all(arr.map(async (num) => {
    // 模拟异步操作
    await new Promise(resolve => setTimeout(resolve, 1000));
    return num * 2;
  }));
  console.log(results); // [2, 4, 6]
};
asyncMap();

father:: JavaScript