学习中心 /编程 /Node.js /进阶提高 /异步:Promise 与 async
🟢 Node.js 进阶提高 💾 下载配套软件

异步:Promise 与 async

回调地狱的现代解法。

📅 2026-11-23 👁 17 次阅读

本节要解决的问题

回调地狱的现代解法。

核心要点

  • Promise 表示未来结果
  • async 函数返回 Promise
  • await 暂停当前函数执行
async function main() {\n  const r = await fetch("https://example.com");\n  console.log(r.status);\n}
循环里需要串行 await 时,注意别误用 forEach。

本文依据 W3School 教程目录整理知识点后由本站原创撰写,非原文转载;原始目录页面当前不可访问。