StaticVariable StaticVariable - 1 year ago 85
HTML Question

change global variable value using a local function in java script

I have written a very simple java script code. I want to change the value of global variable using a local function. I want that when I call the

function than the output should be "2". How can I perform this

var xhr=1;

function vari(){

function value1(){
//here the value should be 2

Answer Source

Your code works fine! You have to invoke vari() though, but you know that, right? You cannot expect variables to change, if you do not call the functions that change the values!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download