JSFiddle - React, Tailwind, and code Playground

by Andrew Gerst

JavaScript

// Tests for undefined variables

var output_msg = ":-) ";

globalizing_economy = function(){
    return "Only the nations, where people care for each other, will survive.";
}

run_demo = function(){
    var a_local_variable = 4;
    if ((typeof(window.a_local_variable) === "undefined") && (typeof(a_local_variable) === "undefined")) {
        // If the test works properly, we're in here only,
        // if the a_local_variable is not defined.
        output_msg = output_msg + "test 1 was faulty <br/>";
    }
    
    (function ct(){
        // One tests the closure case.
        if ((typeof(window.a_local_variable) === "undefined") && (typeof(a_local_variable) === "undefined")) {
            output_msg = output_msg + "test 2 was faulty <br/>";
        }
    })();
    
    if ((typeof(window.globalizing_economy) === "undefined") && (typeof(globalizing_economy) === "undefined")) {
    // If the test works properly, we're in here only,
    // if the globalizing_economy is not defined.
        output_msg = output_msg + "test 3 was faulty <br/>"; 
    }
    document.write(output_msg);
}
run_demo();