Update index.js

Added missing hasOwnProperty check to for .. in loop.