f = families[i]
- an expression that returns the value of families[i]
. (It also has the side effect of assigning this value to f
)
If families.length === 2
, then families[2] === undefined
, then the expression returns undefined
, which is false and breaks the loop.
For more fun breaking you can turn
for (var i = 0, f; f = families[i]; i++) {
in
for (var i = 0, f; f = families[i++]; );
You may need to replace ;
by ,
and replace line i
with i-1
. You also just killed readability.
It should also be noted that the for loop is dumb for readability.
Object.keys(families).forEach(function(key) { var family = families[key]; });
We read significantly.
source share