Skip to content

Instantly share code, notes, and snippets.

@bluepnume
Created January 27, 2017 18:50
Show Gist options
  • Select an option

  • Save bluepnume/362297a9d4cb1426df65a866e25fb12b to your computer and use it in GitHub Desktop.

Select an option

Save bluepnume/362297a9d4cb1426df65a866e25fb12b 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
3:5 error 'total' is assigned a value but never used no-unused-vars
8:10 error 'total' used outside of binding context block-scoped-var
8:10 warning 'total' was used before it was defined no-use-before-define
9:13 error 'total' is already declared in the upper scope no-shadow
12:12 error 'total' used outside of binding context block-scoped-var
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment