Added missing hasOwnProperty check into for-each

Without this kind of hasOwnProperty check, for-each loops break if properties have been added to Object.prototype.