JS 4U 25: Booleans
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: javascript, booleans
Enclosures:
[js4u25-iPhone.m4v ( Size: 3368848 )]
Comments
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:
Boolean(0);
Boolean(1);
Boolean("true");
or
!!0;
!!1
!!"true"
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.
}