Hoisting in JavaScript

Video

JavaScript Notes

JavaScript
    // hoisting
    // the process of taking two passes through the js file
    // first pass hoists all variable declarations to the top of the file 

    var a; 
    var b = 4;
    console.log(d); // would return undefined, as var d is hoisted and declared, but not assigned anything at this point 
    c ( ) ; // this will work, as the function gets hoisted to the top of the page
    function c ( ){
        // function declaration
    }
    var d = 5;
    e ( ); // would return undefined, as var e is not assigned anything at this point 
    var e = function ( ){
        // function expression
    }