Conditional statements without braces
Why you should use braces in conditional statements
HTML
<input type="button" id="tester" onclick="test();" value="Fire Example"/>
JavaScript
var test=function(){
if (1 === 1) {
alert("Case 1");
}
/*This is why you use braces in all if statements */
if (1 === 2)
alert("Case 2a");
//this will fire regardless
alert("Case 2b");
/*javascript sees this as what follows*/
if(1===2){
alert("Case 2a");
}
alert("Case 2b");
};