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.
i agree! that's for a second pass - this is basically so i can get actual, working (non-buggy) code in as a submodule