Use of the native javascript forEach

The forEach method in JavaScript is a standard from the new ECMA5 script specifications.
It can be used as it is if the applied to a node list, such as something returned from a function like document.querySelectorAll(”) or document.getElementById(‘id’).
The whole point of this trick it’s this one:

We add the forEach prototype method to HTML collections and arrays.

So I have prepared a simple script that generates a table and colorize the table using the native forEach method.

You can download the code from here.

Ti Potrebbe Interessare Anche: