![]() |
global variable problem
Code:
if(true){ |
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">All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit. |
Quote:
|
Quote:
http://stackoverflow.com/questions/5...variable-scope Code:
<script type="text/javascript"> |
i understand the example u showed me.but in the code i showed above,i think 'a' is a local variable,so in my opinion,alert(a) should pop up 'undefined' or sth,but it's '2',that's what confused me.
|
Quote:
|
Quote:
|
kinda different from java
|
Quote:
|
| All times are GMT +1. The time now is 08:43 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.