If ([] == false) is true, why does ([] || true) result in []?

前端 未结 3 1556
情深已故
情深已故 2021-01-21 03:31

Was just doing some testing and I find this odd:

[] == false

Gives true, this makes sense because double equal only compares contents and not t

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-21 04:18

    from the ECMA-262 5.1 (page 83):

    If ToBoolean(lval) is true, return lval

    [] || false; // []
    

提交回复
热议问题