Skip to content

Instantly share code, notes, and snippets.

View codeangler's full-sized avatar

Casey Burnett codeangler

View GitHub Profile
var car = "Honda Civic";
showCar();
var showCar = function(){
console.log(car);
};
// Because of hoisting the function expression is hoisted prior to the assignment of the function expression. Thus the call of the showCar(); breaks .
favouriteColor = "green";
function showColor() {
var secondFavouriteColor = "red";
console.log(favouriteColor);
console.log(secondFavouriteColor);
}
showColor();
console.log(favouriteColor);
// doesn't display as local scope
console.log(secondFavouriteColor);
var favouriteColor = "green";
function showColor() {
console.log(favouriteColor);
}
showColor();
function showName () {
console.log("Casey Burnett")
}
showName()