JavaScript

[JavaScript] 최신문법 정리

반응형

Nullish Coalescing Operator(??)

좌항이 null 또는 undefined일 경우에 우항을 반환해준다.

const one = null ?? "One"  
const two = undefined ?? "Two"  
const three = false ?? "Three"

console.log(one, two, three) // One Two false  

 

...

반응형