Variable Scope

Video

JavaScript Notes

JavaScript
    // Variables exist within certain areas of your code! 
    var name = 'Aragorn'; // global variable
    function x ( ){
        var name = 'Gimli'; // local variable console.log(name);
        other = 'Legolas'; // not declared, so a global variable is declared and created
    }
    
    console.log(name); x ( );
    console.log(other);