Hoisting with var


    console.log(i+j); // 3

    var i = 1;
    var j = 1;
        

Hoisting function and var


    a();

    function a() {
      console.log("a");    # a
    }

    b();                   # TypeError: b is not a function

    var b = function() {
      console.log("b");
    }
        

Hoisting with const


    const randomValue = 21;

    function getInfo() {
      console.log(typeof randomValue);          # ReferenceError: Cannot access 'randomValue' before initialization
      const randomValue = "Hi";
    }

    getInfo();