Du code javascript :
Global scope and function :
Code JavaScript :
//global scope and function
var myGlobal = 10; // is defined
function fun1() {
// assign 5 to oppsGlobal Here
oopsGlobal = 5; // isd defined into the function
}
// only change the code above this line
function fun2(){
var output = "";
if (typeof myGlobal != "undefined"){
output += "my global : " + myGlobal;
}
if (typeof oopsGlobal != "undefined"){
output += " oppsGlobal : " + oopsGlobal;
}
console.log(output);
}
fun1();
fun2();