Please help me understand this loop syntax

    for (var i = 0, f; f = files[i]; i++) {
    ParseFile(f);
    }

I don’t understand how you can have: var i = 0, f;

I’m confused by the f. Am I just initializing f here and setting it to null? I can also read it as “var i = 0, then i = f”.

Hi there,

this:

var i=0, f;

is a shorthand version of:

var i = 0;
var f;

So here, you are just initializing f

Thanks for clearing that up for me, Pullo. Now it makes sense to me.

You’re welcome!
It made me look twice, the first time I saw it :slight_smile: