作为一个非常简短的规则,您可以以相反的方式看待它:||(或)returns the first "truthy" value(如果不存在“真实”值,则为最后一个值)??(无效合并)returns the first "defined" value(如果不存在“定义”值,则为最后一个值)例子x = false || true; // --> true (the first 'truthy' value - parameter 2)
x = false ?? true; // --> false (the first 'defined' value - parameter 1)