Invalid prototype value¶
null or another object. The prototype of an object can be set in two ways, both of which guard against attempts to assign an invalid prototype (such as a primitive value):
Assigning a value to the object’s
__proto__property; if the value is not a valid prototype, the assignment is silently ignored.
Using the standard library functions
Object.setPrototypeOf; invalid prototype values lead to a runtime error. In summary, any attempt to set the prototype of an object to a value that is not an object or
nullwill be ineffective and may lead to a runtime error.
Fix the prototype assignment by providing a valid prototype value.
The following code attempts to create an object with prototype
undefined, which will cause an error at runtime:
let dict = Object.create(undefined);
If the intention is to create an object without a prototype object,
null should be used instead:
let dict = Object.create(null);