. .


JS 4U 25: Booleans

January 20, 2011 6:41:19.708

Javascript 4 U

Today's Javascript 4 You. Today we take a look at the Boolean class in Javascript. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube.

Join the Facebook Group to discuss the tutorials. You can view the archives here.

To watch now, click on the image below:


If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Technorati Tags: ,

[js4u25-iPhone.m4v ( Size: 3368848 )]

posted by James Robertson


Re: JS 4U 25: Booleans

[Peter Galiba] January 21, 2011 6:04:27.081

Do not use new Boolean, or the Boolean object altogether. Use the boolean primitives instead. To generate boolean primitives from the values in the video, just either use Boolean without 'new', or the '!' operator 2 times. Example:








Why do i say that? Because the Boolean object may behave strangely:

document.write(new Boolean(new Boolean(false))); // output is "true"

var x = new Boolean(false);

if (x) {

alert(true); // This will be alerted, although the x should be false, but it is an object, and every object is truthy.


 Share Tweet This