javascript - explain the comma separated for expression -


i'm trying track down bug in ember.js source code when came across loop:

for (operationindex = rangestart = 0, len = this._operations.length; operationindex < len; rangestart = rangeend + 1, ++operationindex) { 

the constituent parts broken down looks multiple declarations, e.g.:

operationindex = rangestart = 0, len = this._operations.length 

can explain declaration , can assume loop counter initilaized 0 given above expression?

taking "template":

for (a; b; c) 

there 3 parts in loop declaration. first part (a) executed once before actual loop begins, , used declare loop iterator can used other things.

the second part (b) stop condition: it's being evaluated in beginning of each iteration, , when returning false, loop ends.

the third part (c) executed in end of each iteration , used change loop iterator loop end @ point.

to focus again on specific question, comma used separate 2 variable assignments.


Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -