Categories




PreviousNext
Global variables in Javascript    
 Send mail Views:156
Belongs to : Javascript
Facebook Bookmarkbookmark this page Digg Bookmark Delicious BookmarkStumbleupon Bookmarkshare with orkut Post to Google Buzz

Global variables in Javascript:

Normally we declare global variables outside all functions as,
var test = 5;
function result(){
var calc = parseInt(test)+5; //Something like that......
}


But if you want to define a variable as global inside a function then use the following steps:
* First, declare the variable as,
var Globalvar = value;

* Then use make it as global by using the keyword "window" as,
window.Globalvar = value;

for eg,
function test(){
var Globalvar = somevalue;
window.Globalvar = somevalue;
}
function test1(){
alert(window.Globalvar);
}


Pictures and Videos
Online Calculators
embed code


By - Ramya, On - 2010-06-17
Send This
PreviousNext

User Comments


Add NEW Feedback:

Name :     Email :

 Server Monitoring Web hosting by Hiox India Privacy Policy Terms and Conditions