Conversion of js true and false empty array

let obj ={
        a :true,
        b:[]
    }
if(obj.a && obj.b){
  console.log(324)
}
//324 obj.b

//
obj.b => [] => Boolean([]) => true
//
[]===[]
//false

* *

< H2 > add: how can I modify it if I want to implement the usual function that only executes 1 for true? This array is sometimes a non-empty array < / H2 >

* *

Oct.11,2021

[] typeof = > "object" and then convert to true
null except for objects

clipboard.png


if==;
ifObjecttrueTo Boolen;
==ToPrimitive;
[]===[]:[]false




obj.b

: [] == false true
https://www.cnblogs.com/nanch...


obj.a = true
obj.b = [] true







true

clipboard.png


this is the difference between js and python. Empty arrays and empty objects are all true


any object that converts Boolean to true

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-1e37c3f-437b8.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-1e37c3f-437b8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?