1. [] and! []

[] = =false/ / = >true! [] = =false/ / = >true[] = =! [] / / = >true[] = = [] / / = >false
if( [] )
    console.log("true"); / / = >log: "true"
Copy the code
  • Can be true or false[]

2. “and “”

""= =false/ / = >true
""= =false/ / = >true
""= =""/ / = >false
if("")
    console.log("true")
else console.log("false") / /log: "false"

if("") 
    console.log("true") / /log: "true"
Copy the code
  • Can be true or false""
  • while""Constant for thefalse

3. “0” and 0

0 = =false/ / = >true
"0"= =false/ / = >true
"0"= > / = = 0"true
if("0") 
    console.log("true") / /log: "true"
Copy the code
  • Can be true or false"0"
  • 0Constant for thefalse

Mixed 4.

[] = = 0 / / = >true[] = ="0"/ / = >false[] = =""/ / = >false[] = =""/ / = >true0 = =""/ / = >true0 = =""/ / = >true
Copy the code

Conclusion: There are several special cases

    1. [] == "" == 0 == false
    1. "0" == 0 == false
    1. " " == 0 ==false

In addition,[],"","0"Will not be seen asfalse.

This is probably something we should try to avoid= =One of the reasons.

(PS: The main reason should be abhorrent:"1" = = 1)

Ps2: Where it still worksnull == undefined)