To solve this kind of conversion problem in detail.

I can"t tell you how to analyze it.

if ([] = = false) {console.log (1)};

if ({} = = false) {console.log (2)};

if ([]) {console.log (3)}

if ([1] = = [1]) {console.log (4)}

ask the Great God for a detailed explanation

Apr.03,2022

compared with boolean type boolean will be converted to numeric false 0 true 1
and numeric type comparison will be converted to numeric type complex type will take valueOf method
so the first [] = = false = > [] = 0 [] does not rewrite valueOf by default, so toString array toString defaults to join, so finally "= = 0 primitive type and numeric comparison will take Number method, namely Number (" ") return 0 last zero true
the first reason is the same, but {} toString is" [object Object] "Number is NaN so {} = = false is false
the third complex type is converted to boolean type is true
the fourth complex type is compared with the complex type is the memory address, so [1] = = [1] is false

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bcfa3c-131d6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bcfa3c-131d6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?