I am using JavaScript and I create a global variable. I define it outside of a function and I want to change the global variable value from inside a function and use it from
var a = 10; myFunction(a); function myFunction(a){ window['a'] = 20; // or window.a } alert("Value of 'a' outside the function " + a); //outputs 20
With window['variableName'] or window.variableName you can modify the value of a global variable inside a function.