To further refine the accepted answer it's worth noting that if you instantiate the object with a var object = Object.create(null)
then object.hasOwnProperty(property)
will trigger a TypeError. So to be on the safe side, you'd need to call it from the prototype like this:
for (var property in object) {
if (Object.prototype.hasOwnProperty.call(object, property)) {
// do stuff
}
}