var salary = "1000$";
(function () {
    console.log("Original salary was " + salary); //1000$
    salary = "5000$";
    console.log("My New Salary " + salary); //5000$
})();
(function () {
    console.log("Original salary was " + salary); //undefined ?? 
    var salary = "5000$";
    console.log("My New Salary " + salary); //5000$
})();
Why and how first and third console logs are displaying different outputs ?
 
     
    