Diferencia entre Object.prototype.hasOwnProperty.call y {} .hasOwnProperty.call. (Eslint rule guard-for-in)
En la regla del eslintguardia para entrar , utilizarfor in
directamente es incorrecto La buena practica es
for (key in foo) {
if (Object.prototype.hasOwnProperty.call(foo, key)) {
doSomething(key);
}
if ({}.hasOwnProperty.call(foo, key)) {
doSomething(key);
}
}
Mi pregunta es cuandoObject.prototype.hasOwnProperty.call(foo, key)
y{}.hasOwnProperty.call(foo, key)
conducirá diferente resultado? ¿Alguien puede mostrar un ejemplo específico?