Welcome visitor
* Login
* Register
It is currently July 23rd, 2019, 7:18 am
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
  Methods to declare a variable in JavaScript
PostPosted: August 6th, 2009, 1:01 pm 

Posts: 31
I always thought that i needed to declare variables using the var statement first. But lately, and I dont remember where, I read that it was the same if i wrote or not the var prefix, is it true?

example
var x=5 == x=5


Top
 Profile  
 
  Re: Methods to declare a variable in JavaScript
PostPosted: August 7th, 2009, 4:31 am 

Posts: 16
yes both methods are the same. the exception is if you write var x inside a function you will create a new x variable and you will not be refering to the global x variable, in other words, if you are inside of a function and would like to change the value of a global variable never put the "var" before the variable.


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