While the prototype property is used by the language to build the prototype chains, it is still possible to assign any given value to it. However, primitives will simply get ignored when assigned as a prototype.
function Foo() {}
Foo.prototype = 1; // no effect
It says Foo.prototype = 1 will get ignored and has no effect. But it's not.
function Bar(){}
(new Bar).constructor // function Bar(){}
function Foo(){}
Foo.prototype = 1
(new Foo).constructor // function Object() { [native code] }
(new Foo).constructor is not function Foo(){} anymore. So it's obviously affected by the assignment expression.
Assert: intrinsicDefaultProto is a String value that is this specification's name of an intrinsic object. The corresponding object must be an intrinsic that is intended to be used as the [[Prototype]] value of an object.
Assert: IsCallable(constructor) is true.
Let proto be ? Get(constructor, "prototype").
If Type(proto) is not Object, then
Let realm be ? GetFunctionRealm(constructor).
Let proto be realm's intrinsic object named intrinsicDefaultProto.
Return proto.
So to the point, it's not no effect, nor ignored. Usually Object in implementations.
https://bonsaiden.github.io/JavaScript-Garden/#the-prototype-property
It says
Foo.prototype = 1
will get ignored and has no effect. But it's not.(new Foo).constructor
is notfunction Foo(){}
anymore. So it's obviously affected by the assignment expression.This is described in ECMA-262: 9.1.14 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ), step 4 is the key point:
So to the point, it's not no effect, nor ignored. Usually
Object
in implementations.Credit goes to this post from StackOverflow.