View Single Post
Old 10-05-2012, 07:51 AM   PM User | #3
BaronZ
New to the CF scene

 
Join Date: Oct 2012
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
BaronZ is an unknown quantity at this point
Quote:
Originally Posted by Philip M View Post
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'?
BaronZ is offline   Reply With Quote