Welcome visitor
* Login
* Register
It is currently July 19th, 2019, 6:32 pm
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Client Side » JavaScript



Post new topic Reply to topic  [ 2 posts ] 
Author Message
  global variable is working as local variable
PostPosted: June 1st, 2009, 8:44 pm 

Posts: 46
<script type="text/javascript">
var ms;
ms=1;
function a(){
var ms=0;
alert(ms);}
function b(){
alert(ms);}
</script>

if i call function a the alert sends a value of 0, thats fine, but if after that i call function b now it alert a value of 1. why isnt function b returning the value function a gave to ms?


Top
 Profile  
 
  Re: global variable is working as local variable
PostPosted: June 1st, 2009, 9:24 pm 

Posts: 96
Your function A is creating a local variable,

change
var ms=0;
to
ms=0;


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

FORUMS » Client Side » JavaScript


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron