redux - What JavaScript Syntax is this? -
here's sample redux.js reding on github. can please explain syntax used here?
var currentlisteners = [] var nextlisteners = currentlisteners .... somefunc() { // this: var listeners = currentlisteners = nextlisteners (var = 0; < listeners.length; i++) { listeners[i]() } ..... }
are multi-assignment , statements independent? explain it. missing semicolon @ end of assignment? practice / bad practice?
the assignment operator evaluates whatever has been assigned (effectively right operand). side effect, updates value of left operand. a = b = c
assigns value of c b, evaluates c, , assigns value of c a, , evaluates c.
assignment right-associative -- groups right left.
further, semicolons between statements [semi-]optional if each statement on own line (there detail missing here that's covered in link).
finally, 1 interesting thing going on here assignment variable declared 1 scope up. functions in javascript 1 way declare new scope. note if function being defined in snippet, won't have effect on value of currentlisteners
until it's called.
Comments
Post a Comment