Js Js conversion of each of the types of data into various types of data bool conversion to bool

Js each data type conversion to bool

 

 

In return problems encountered by the front desk Json string, the returned data is always TRUE bool

Specially I checked and found that the results of various types of data Js converted to type bool yes.

We hope to give people experiencing the same problem a little help.

 Converting the value of data type BOOL
null --------------------- FALSE
undefined -------------- FALSE
Object - TRUE ----------------
function TRUE ---------------
0 --------------- FALSE ---------
. 1 ------------------------ TRUE
number other than 0 ------- - TRUE
string TRUE -------------------
"" (an empty string) ------------- FALSE 

 

 

In return problems encountered by the front desk Json string, the returned data is always TRUE bool

Specially I checked and found that the results of various types of data Js converted to type bool yes.

We hope to give people experiencing the same problem a little help.

 Converting the value of data type BOOL
null --------------------- FALSE
undefined -------------- FALSE
Object - TRUE ----------------
function TRUE ---------------
0 --------------- FALSE ---------
. 1 ------------------------ TRUE
number other than 0 ------- - TRUE
string TRUE -------------------
"" (an empty string) ------------- FALSE 

 

 

Guess you like

Origin www.cnblogs.com/jiangyuzhen/p/10978537.html