ESLint(no-prototype-builtins)

// eslint-disable-next-line no-prototype-builtins

​ if (!a.hasOwnProperty(key) || !b.hasOwnProperty(key)) return 0;

no-prototype-builtins - Rules - ESLint - Pluggable JavaScript linter

Rule Details

This rule disallows calling some Object.prototype methods directly on object instances.

Examples of incorrect code for this rule:

1
2
3
4
5
6
7
/*eslint no-prototype-builtins: "error"*/

var hasBarProperty = foo.hasOwnProperty("bar");

var isPrototypeOfBar = foo.isPrototypeOf(bar);

var barIsEnumerable = foo.propertyIsEnumerable("bar");

Examples of correct code for this rule:

1
2
3
4
5
6
7
/*eslint no-prototype-builtins: "error"*/

var hasBarProperty = Object.prototype.hasOwnProperty.call(foo, "bar");

var isPrototypeOfBar = Object.prototype.isPrototypeOf.call(foo, bar);

var barIsEnumerable = {}.propertyIsEnumerable.call(foo, "bar");