Skip to content

Instantly share code, notes, and snippets.

@abel-masila
Created December 6, 2017 11:35
Show Gist options
  • Select an option

  • Save abel-masila/5f91666dba3a10ce76d972b421883344 to your computer and use it in GitHub Desktop.

Select an option

Save abel-masila/5f91666dba3a10ce76d972b421883344 to your computer and use it in GitHub Desktop.
//Hoisting
y = 80; // Assign 5 to x
x=y+5 // sum up 5 with the value of y
var y; // Declare y
//JavaScript only hoists declarations, not initializations.
var name = "Abel";
(function () {
// Outputs: "Original name was undefined"
console.log("Original name was " + name);
var name = "Multithread";
// Outputs: "New name is Underhill"
console.log("New name is " + name);
})();
//function hoisting
// Outputs: "Yes!"
isItHoisted();
function isItHoisted() {
console.log("Yes!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment