Nullish coalescing operator
null 병합 연산자(Nullish coalescing operator) ??
는 명시적으로 조건이 null
또는 undefined
인 경우 대체 값을 처리할 때 유용하게 사용됩니다.
function nullish(n) {
return n && 0
}
// ————————————————————————————————————————————————————
function nullish(n) {
return n != null ? n : 0
}
const el = (selector, context) => (context ?? document).querySelector(selector)
Last updated
Was this helpful?