Skip to content

Instantly share code, notes, and snippets.

@codeangler
Created May 21, 2016 03:22
Show Gist options
  • Save codeangler/f82499a727e77f74b1685c9da11672b0 to your computer and use it in GitHub Desktop.
Save codeangler/f82499a727e77f74b1685c9da11672b0 to your computer and use it in GitHub Desktop.
https://repl.it/mVA/166 created by codeangler
var food = "pizza";
function getFood(){
console.log(food); //what does this line alert?
// Assigning var food is hoisted w/n function w/o assignment and first console.log returns undefined. Then var food is assigned saugages and returns "sausages"
var food = "sausages";
console.log(food); // what does this line alert?
}
getFood();
Native Browser JavaScript
>>> undefined
sausages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment