Performance. Or at least possibly performance.
The hasOwnProperty
method is attached directly to Object.prototype
, so when one calls {}.hasOwnProperty('foo')
, the JavaScript engine first checks the object directly for a hasOwnProperty
method, and if it does not exist there, it goes up the prototype chain again, to check if it exists one level up. Rinse. Repeat.
In the example given in this answer, the JS engine only goes on level up, since the object in question was an object literal. If you were test this on a constructed instance, such as a Date object, then there are more levels up the prototype chain the engine must traverse to get the appropriate method. This is not much of a performance hit for most objects, and in fact for object literals, it more performant on some engines to use the instance method as opposed to the statically called function, but if Object.prototype is several layers above an object ancestrally in the prototype chain, then the performance hit becomes more measurable.
@Frits van Campens's answer does not hold water, however, because one could also override Object.prototype.hasOwnProperty
.