Functions - Example 4

Take a look at this program:

<script language="JavaScript">
var a = 10, b = 45;
if (a == 10 || b == 45)
 document.write("The condition passed!");
</script>

The condition is an OR condition (because of the || part). It succeeds because the first clause (a == 10) succeeds - in fact, it doesn't really need to test the second clause at all!

But does it test the second part anyway? Does the program test both parts of the OR clause even though the first clause is enough for the condition to pass, or does it skip the second part (so-called "short-form evaluation")? Make a note of the number below and then take a look at the source code for this page. Then see if you can answer that question!