Understanding JavaScript Truthy and Falsy

后端 未结 7 1977
深忆病人
深忆病人 2020-11-22 08:20

Can someone please explain JavaScript Truthy and Falsy, using the below sample data. I have read other threads but still confused.

var a = 0;

var a = 10 ==          


        
7条回答
  •  眼角桃花
    2020-11-22 08:48

    FALSY

    • false
    • 0 (zero)
    • "", '', `` (empty strings)
    • null
    • undefined
    • NaN (not a number)

    note : Empty array ([]) is not falsy

    TRUTHY

    • Everything that is not FALSY

提交回复
热议问题