function hasPrototypeProperty(object, name) {
    return !object.hasOwnProperty(name) && (name in object)
}

原理:
hasOwnproperty()方法会返回一个布尔值,检测属性是否存在于对象中(实例),但不能检测原型中的属性

in操作符 如果指定的属性在指定的对象或其原型链中,则 in 运算符返回true

转自:https://blog.csdn.net/qq799028706/article/details/86380447

相关文章:

  • 2022-12-23
  • 2021-11-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2018-06-14
相关资源
相似解决方案