Understanding JavaScript Truthy and Falsy

后端 未结 7 1893
深忆病人
深忆病人 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 09:00

    Truthy -> Value that resolve to true in boolean context

    Falsy -> Value that resolve to false in boolean context


    For better understanding, falsy values is given below.

    1. false
    2. 0
    3. empty string
    4. null
    5. undefined
    6. NaN

提交回复
热议问题