Answers for "how to change global variable inside a function javascript"

33

javascript define global variable

window.myGlobalVariable = "I am totally a global Var"; //define a global variable
var myOtherGlobalVariable="I too am global as long as I'm outside a function";
Posted by: Guest on August-02-2019
0

change a variable outside a function js

var global = "Global Variable"; //Define global variable outside of function

function setGlobal(){
       global = "Hello World!";
};
setGlobal();
console.log(global); //This will print out "Hello World"
Posted by: Guest on September-12-2020

Code answers related to "how to change global variable inside a function javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language