Do not access Object.prototype method ‘hasOwnProperty‘ from target object....

问题描述

在使用hasOwnProperty()方法时报错:
Do not access Object.prototype method ‘hasOwnProperty’ from target object.eslint(no-prototype-builtins)
Do not access Object.prototype method ‘hasOwnProperty‘ from target object...._第1张图片

不要访问目标对象的原型方法“hasOwnProperty”

解决方案:

//错误的
if (obj.hasOwnProperty(key)){
           ...
}
//正确的
if(obj.prototype.hasOwnProperty.call(key)){
			...
}

你可能感兴趣的:(bug?报错小本本,原型模式,javascript,前端)