Quote:
Originally Posted by Philip M
Why do you think that a is global? If your code is within a function then a is local, and alert (a) results in the value of a being alerted.
Code:
<script type="text/javascript">
var a =10;
function test() {
var a = 12;
alert ("Local " + a); //12
}
alert ("Global " + a); //10
test();
</script>
if(true) is meaningless as the condition will always be true.
All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.
|
umm,but if a is not global,why the alert box shows '2'?