Additional Topics
Truthy vs. Falsey
What happens if we put something other than a Boolean as the conditional in an if statement?
http://james.padolsey.com/javascript/truthy-falsey/
var person = null;
if (person) {
console.log("this will not be printed");
} else {
console.log("this will be printed");
}
var num = 0;
if (num) {
console.log("this will not be printed");
} else {
console.log("this will be printed");
}
var num = 5;
if (num) {
console.log("this will be printed");
}
Common Mistakes
- Using the assignment operator(=) instead of the equality operator(===)
- Infinite loops!