Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> JavaScript >> Snippet

07 Boolean logic


Boolean refers to logical relationships - True or False, and is named
after mathematician George Boole.

//There are four values which JavaScript treats as False.  All other values are True
0    zero
""    zero length string
null    null value
undefine variables whose value has yet to be assigned

Boolean values used in mathematical expressions are converted to mathematical values as follows :
False becomes 0     i.e.  False * 2 = 0
True becomes 1      i.e.  True * 5 = 5

If A Then    
    '0 value is treated as False
    'non-zero value is treated as True
End If