fixed IE8 issue with for in loop

The demos on the wiki page don't have the piece of code where changes have been made in this commit. So they work fine.I had issues with this piece of code when I was testing in IE8.Hence fixing the same