LeoWangJ / blog

紀錄學習文章
1 stars 0 forks source link

JS的falsy值 #21

Open LeoWangJ opened 4 years ago

LeoWangJ commented 4 years ago

falsy的意思是在Boolean中可以轉變為false的值,總共有五個。

  1. 0
  2. NaN
  3. null
  4. undefined
  5. ""
console.log(!!0) // false
console.log(!!NaN) //false
console.log(!!null) //false
console.log(!!undefined) //false
console.log(!!"") //false