Extract `extend` and `hasOwnProp` utilities out.

`extend` uses `hasOwnProp`, and `hasOwnProp` is there mostly for safety. You cannot always assume it will be present on a random object, so it's better to use it as shown in this commit.