define global func js code example
Example 1: access method globally js
window.checkCookie = function(){
// do whatever you want here
};
Example 2: 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 3: create global variable inside function JavaScript
<script>
function foo() {
window.yourGlobalVariable = ...;
}
</script>