Fixing compatibility for IE8 (and maybe older)

IE8 and older don't have `Array.forEach`, so we have to use a classic `for` loop. According to http://kangax.github.io/es5-compat-table/ this commit should fix the patterns for IE7 and IE6 too but I didn't check.

Sorry if my JavaScript sucks.