➕nullish coalescing (??)
🚧 under construction
JS ⟩ statement ⟩ expression ⟩ operator ⟩ logical ⟩ nullish coalescing operator (??)
?? operator
the precedence of
??relative to||,&&is not defined.explicitly use parentheses if
??is mixed with||,&&.
??may be used after optional chaining (?., ?.[]) to provide a default value.
// ⭐️ nullish coalescing
x = x ?? 100;
// polyfill
x = (x !== undefined && x !== null) ? x : 100;
// ❗️ slightly different from:
x = x || 100;問:「 Google Apps Script 支援 nullish coalescing 嗎?」
答:「 測試過,看來是支援的。」
Last updated
Was this helpful?
