Javascript boolean interpretation
I have two simple questions for you about boolean values in Javascript.
When will browser show alert message:
if (a-b) alert("it's true!");
And another one
What will be printed as result of running this script:
for (var n=10; n; n-- )
{
document.write (n + ",");
}
The answer for both questions relies on the same principle of what JavaScript engine will evaluate as true and what as false.
A few posts you might find interesting:
Categories: Browser, Interview Questions, JavaScript, Tips & Tricks

1.
If (a-b) is non zero, then “It’s true” alert message is displayed.
If value a and b is same, (a-b) evaluates to 0, then no alert message.
Сheck the variable is always the equivalent of comparing a variable to null
If only I had a buck for each time I came to kossovsky.net! Amazing post.