3 ms·
Yes: for each (...) -> It's not supported anywhere, so forget it. for (var x in a) -> x is the key, so it's kind of inconvenient. You have to watch out for in
by kolme 11y ago
Yes:
for each (...) -> It's not supported anywhere, so forget it.
for (var x in a) -> x is the key, so it's kind of inconvenient. You have to watch out for inherited properties/methods so one should check for a.hasOwnProperty(x).
for (var x of a) -> It has mostly no gotchas. Only poor browser support.
.forEach only works with arrays and from ES5 on. You have the good old "this"/scope gotcha.