JavaScript - Hoisting
// JavaScript - Variable and function hoisting:
var salary = "1000$";
(function () {
console.log("Original salary was " + salary);
var salary = "5000$";
console.log("My New Salary " + salary);
})();
The above code log 'undefined, 5000$' to the console. This is due to variable
hoisting.
page revision: 1, last edited: 14 Nov 2016 07:29





