空值合并运算符 ??
只有当左侧结果为null和undefined时才返回右侧的结果(与 || 不同)。
示例:
let a = "hello" ?? 1;
console.log(a); // 'hello'
let b = null ?? 1;
console.log(b); // 1
let c = undefined ?? 1;
console.log(c); // 1
let d = "" ?? 1;
console.log(d); // ""
let e = 0 ?? 1;
console.log(e); // 0