Introduction
Overview
History
Advice
Books
Tutorials
Source Code
Top 100
Reference

Beginners
Sample Code
IDE
Syntax
Variables
Boolean Logic
Strings
Arrays
Conditional Flow

Intermediate
Date-Time
Math
Functions
Event Handlers
Error Handling

Advanced
Objects
Dynamic HTML
Cookies
Multimedia
CGI
Java Applets
Distribution

Community
Web Sites
Mailing Lists
USENET
Vendors
News

GBIC >> JavaScript >> 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
    nullspecial null value
    undefinedvalue has not been assigned

Boolean values may be used in mathematical expressions and are converted to mathematical values as follows:

  • false becomes 0
  • true become 1

Examples:

false * 2    //evaluates to 0
true * 5     //evaluates to 5
if A then
    '0 value is treated as False
    'non-zero value is treated as True
end if