Thursday, 12 March 2015

Enhanced For Loop in JavaScript

I am no expert in JavaScript, but I feel I should mention the possible flavours of for loops in here.

The forEach method is explained in [4].

The latter example is new in ECMAScript 6 (which should be out already).3

You can test it out in [5].


[1] Mozilla Developer Network - for...of
[2] Stackoverflow - For-each over an array in JavaScript?
[3] ECME-262 6h Edition, The 2015 ECMAScript Language Specification ("Harmony")
[4] forEach
[5] JSFiddle - example in action

No comments:

Post a Comment