728x90
- Logical - || (falsy)
falsy 일 때만 오른쪽 값을 채택 - nullish coalescing operator - ?? (undefined/null)
null/undefined 일 때만 오른쪽을 채택
> 0 || 1
1
> 0 ?? 1
0
> null || 1
1
> null ?? 1
1
> "" || 1
1
> "" ?? 1
''
> undefined || 1
1
> undefined ?? 1
1
> NaN || 1
1
> NaN ?? 1
NaN
The difference between || and ?? operators in Javascript & NodeJS
In short, the difference between the two operators boils down to the difference between falsyand null/undefined. Where the logical or (||…
medium.com
https://ko.javascript.info/nullish-coalescing-operator
nullish 병합 연산자 '??'
ko.javascript.info