Web appOpen in Telegram
JJavaScript/Node.js 台灣
JavaScript/Node.js 台灣
@JavaScriptTw · group · Tech · indexed since 2026-07-05 archive for February 2022
1 999members−15 in a week
4writing in 30 days
15messages in 30 days
103 295messages in the index

Messages from February 2022

‹ February 2022 ›×
R
唉,为什么感觉应该是标准的概念都会出现分歧
  1. R
    大部分时候都应该 await 吧,只有少数不阻塞也不会影响后续流程的时候才可以不 await
Whole thread · 1 reply →
阿
async function foo(a) { if (a) { return anotherPromise(); } else { return 2; } }
  1. R
    这是因为 promise 刚好是返回值啊,加不加无所谓
Whole thread · 3 replies →
阿
当然你可以选择这样写。 function foo(a) { if (a) { return anotherPromise(); } else { return Promise.resolve(2); } }
R
吾辈一般的写法(ide 会提示加上 async function foo(a) { if (a) { return await anotherPromise() } else { return 2 } }
Whole thread · 1 reply →
Whole thread · 1 reply →
Y
async function foo(a) { if (a) return await anotherPromise(); else return 2; }
M
我覺得是情境問題 假設有 a, b, c 三支API 需要調用 c 必須由 a 和 b 取得資料後才可調用 那此時 call c 之前是否需要阻塞分別等待 a 和 b 異步完成調用? 此處 API 換成 SQL 或 fs 調用亦同

An open public feed from the search index ChatCrawler — “Google for public Telegram”; refreshed as the venue is crawled. Times are UTC.

Public content only, official Telegram API. About · FAQ · What we do not do · Remove a page · Catalog · Search · How we count