add checks for hasOwnProperty and used forEach where useful

when Object.prototype is modified (or Array.prototype, for that matter), we can no longer iterate over the keys (or elements, respectively) using `for (var ... in ...)`. Added a hasOwnProperty check for object key iteration, and used `.forEach` for array element iteration instead.
That's also reasonable. I find both clear