Message from JavaScript discussions

March 2018

— For of is alright


No technical reason I can think of other than performance. for/of is for iterators, and iterators are a bit slower than normal accessor based enumeration

— But really, performance usually isn’t a big concern unless your code is high load

— In that case avoid iterators in general, and only use the standard for loop with the 3 expressions

— That is the fastest loop

— Pretty much

— MDN had a line advising against for...of on Arrays

— Okay that's something else

— Right,

— ForEach locks block in the scope, sometimes useful, sometimes (more often) not

— Sometimes to reuse variable name, if having a, b, c in block, it may be done with a.forEach (a) -> and with for you have to make var d

Message permanent page

— Hello everyone