In Javascript, all variable declarations are hoisted to the top of the scope in which they are declared before any code is actually run. So your code example:
(function () {
var _a = 1;
_c = _a;
var _c;
})();
console.log(_c);
Is evaluated like this:
(function () {
var _a;
var _c;
_a = 1;
_c = _a;
})();
console.log(_c);
Thus, _c
is declared locally before it is actually referenced or used and thus it is not an implicit global because it is declared within the scope in which it is referenced and the hoisting ensures it is declared at the beginning of that scope, no matter where the var _c;
declaration is within the scope.
Here are some references on the hoisting concept:
JavaScript Scoping and Hoisting
MDN - var
statement
Demystifying JavaScript Variable Scope and Hoisting
JavaScript Hoisting Explained