In JavaScript, var declarations create properties on the global object:
var x = 15;
console.log(window.x); // logs 15 in browser
console.log(glo
Per the specification:
"let and const declarations define variables that are scoped to the running execution context’s LexicalEnvironment."
This means that you should be able to access the variable inside the execution scope, but not outside. This expands the execution scope beyond the classic JS closure structure of function-only or global.
Defining a let variable globally leaves this open to interpretation, as you see in Firefox it binds a global variable where as V8/iojs does not.
It's worth mentioning that console.log(typeof x) will returl number in iojs. In practice you should not define variables outside of modules, or functions as much as possible... especially with const and let