DevelopPHP
home gear home donate
Search Results For
in:

Libraries book

HTML Library CSS Library JavaScript Library PHP Library

Videosbook

PHP and MySQL JavaScript HTML and CSS Vector and 3D Flash Actionscript Android Dev Miscellaneous

Resourcesbook

Website Hosting Developer Q+A
Sprite Programming Mastery
Boolean Object Javascript

The Javascript Boolean object is the data type for boolean values(true or false). Boolean values are used by programmers of many languages as a way in which they can toggle between true and false in a variable or evaluate expressions. Many expressions in Javascript will result in a boolean value which you can then evaluate using condition logic.

You do not have to use the "new Boolean" syntax and it is said to be more efficient NOT to use the constructor when establishing boolean objects.

Boolean Object Syntax

Javascript CODE EXAMPLE
// Booleans with false value
var a = false;
var b = Boolean();
var c = Boolean(false);
var d = new Boolean(false);
var e = new Boolean(null);
var f = new Boolean("");
var g = new Boolean(0);

// Booleans with true value
var h = true;
var i = Boolean(true);
var j = new Boolean(true);
var k = new Boolean(1);
var l = new Boolean("poop");

All of the approaches shown above will establish Boolean objects in Javascript with initial values of either true or false.

Example demonstrating how to evaluate Boolean objects using an if condition:

Javascript CODE EXAMPLE
var a = false;
if(a){
    document.write("a is "+a+", run code"); // "a" must be true for code to run
}

Example demonstrating how most expressions will result in a Boolean value that can be used for condition logic in your scripts.

Javascript CODE EXAMPLE
var myString = "";
if(myString){
    document.write("The string is "+myString);
} else {
    document.write("The string is null and returns false when evaluated");
}

 

Home   •   Terms of Use   •   T-Shirts   •   RSS   •   Testimonials   •   Subscribe   •   Classroom Chalkboard   •   Developer Q+A   •   Donate   •   Top ↑
Popular In PHP / MySQL E-Commerce Store Production
Social Network Website Building
Image Upload / Photo Processing
CMS Software Programming
Mass Email Systems
Magic XML Data
Search Programming
Popular In JavaScript JSON Programming
Ajax Programming
Animating Elements
WYSIWYG Programming
Date/Time Programming
DOM Scripting
Object Reference
Popular In HTML Canvas Element
New Form Elements
Audio Element
Video Element
Drag and Drop
Event Handling
Element Grouping
Popular In CSS Custom Font Embedding
Dynamic Fit Backgrounds
Theatre Mode
Box Overlays
CSS Level 1 Properties
CSS Level 2 Properties
CSS Level 3 Properties
DevelopPHP.com is a growing educational system packed with video and written material that you can access 24/7 100% free. The focus here in 2014 is spread between five technologies: HTML, CSS, JavaScript, PHP and MySQL. Learn programming theory, database interaction, web design, animation, graphics editing, vector art, 3D modeling, and much more. The educational experience here is a hybrid one offering both high quality video tutorials and code libraries that grow more robust every day. The code libraries are being assembled so that developers can discover all of the building blocks of their favorite languages. The libraries coupled with high quality video tutorials will take you deep down the rabbit hole very quickly. You can also ask questions and get free advice at WebIntersect.com.
HTML5