✏️ nullish
The nullish coalescing (??) operator is a logical operator that returns its right-hand side operand when its left-hand side operand is null or undefined, and otherwise returns its left-hand side operand.
var kor = null ?? 10;//null 로만 한정해서 기본값을 만들고 싶을 때
var kor = false ?? 10;
var kor = false || 10;// falsy를 기반으로 기본값을 만들고 싶을 때
console.log(kor);
https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing
Nullish coalescing operator - JavaScript | MDN
널 병합 연산자 (??) 는 왼쪽 피연산자가 null 또는 undefined일 때 오른쪽 피연산자를 반환하고, 그렇지 않으면 왼쪽 피연산자를 반환하는 논리 연산자이다.
developer.mozilla.org
'IT > JavaScript' 카테고리의 다른 글
| [JS] ✏️ Infinity / ifFinite() (0) | 2023.07.17 |
|---|---|
| [JS] ✏️ NaN (Not a Number) / isNaN() (0) | 2023.07.17 |
| [JS] ✏️ Logical AND(&&) & OR( | | ) (0) | 2023.07.17 |
| [JS] ✏️ Truthy && Falsey (0) | 2023.07.17 |
| [JS] ✏️ eval(), JSON.parse(), JSON.stringify() (0) | 2023.07.17 |