Skip to content

Instantly share code, notes, and snippets.

@bluepnume
Last active January 27, 2017 18:45
Show Gist options
  • Select an option

  • Save bluepnume/6b2cf6b3e2616f13393940900c93b368 to your computer and use it in GitHub Desktop.

Select an option

Save bluepnume/6b2cf6b3e2616f13393940900c93b368 to your computer and use it in GitHub Desktop.
var DEFAULT_TOTAL = 10;
var total = 5;
function getTotal() {
"use strict";
if (!total) {
var total = DEFAULT_TOTAL;
}
return total;
}
console.log('Total:', getTotal());
hoisting.js
#1 'total' used out of scope.
return total; // Line 12, Pos 12
#2 Redefinition of 'total' from line 2.
var total = DEFAULT_TOTAL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment