The __proto__ property of an object should be assigned with a proper value.

  • Error
  • Medium
  • No tags

This rule applies when an invalid value is assigned to the __proto__ property of an object.

Only objects and null can be assigned to the __proto__ property; other values will be ignored.

Note: It is recommended to use Object.getPrototypeOf() and Object.setPrototypeOf() instead of __proto__ property.

Noncompliant Code Example

View with compliant examples side by side
var x = {}
x.__proto__ = undefined; // BAD_ASSIGN_TO_PROTO alarm

Compliant Code Example

View with noncompliant examples side by side
var x = {}
Object.setPrototypeOf(x, null);


This rule was introduced in DeepScan 1.19.0.


Was this documentation helpful?