In a lexically scoped language I would assume that the scoping follows the lexical representation of the code.
In a lexically scoped language the variables belong to the containing lexical scope. That that lexical scope can be a function rather than a block doesn't make Javascript any less lexically scoped (in cases other than the dynamic this).
The variable i is not even defined before it is refered to in the inner function.
The order that variables appear within a scope has no effect on the scoping rules.
For example, in C#:
void Foo() {
i = 10;
int i;
}
Gives "error CS0841: Cannot use local variable 'i' before it is declared". It knows exactly what variable "i = 10" is referring to because it's declared in the same scope, but the language designers have decided to add the rule that you're not allowed to reference it before it's declared (because doing so is most likely a bug).
Incidentally, Javascript made the opposite decision; you can refer to variables before their declaration, they're just "undefined". But in both cases the compiler knows what "i" it's referring to by the lexical scope.