"for each" fix, for modified prototypes

Fix "for..each" in case Array or Object prototypes are modified globally.