javascript - Do I need to create a variable in a for-loop? -


this question has answer here:

i'm new javascript, i'm sorry if question stupid. told when create for-loop, should write:

for (var = 0; < 10; i++) 

but forget put var before i:

for (i = 0; < 10; i++) 

and works same. need create variable i?

what's main difference between

var = 0 

and

i = 0 

in for-loop?

when declare variable var it's scope limited,

when don't use var variable in global scope. means can access variable anywhere.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -