variable declaration in javascript function code example
Example 1: 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";
Example 2: declare function javascript
function myFunction(var1, var2) {
return var1 * var2;
}
Example 3: global scope js
const color = 'blue'
const returnSkyColor = () => {
return color; // blue
};
console.log(returnSkyColor()); // blue