Reputation: 433
It is just for experiment. The following code seems not able to change Object.prototype to null.
Object.prototype = null;
var o = new Object();
Is it just because it is 'Object' or built-in types? I think we can change it for user-defined types. Sorry if I'm wrong
Upvotes: 0
Views: 88
Reputation: 10111
15.2.3.1 Object.prototype specifies that:
This property has the attributes {[[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
and 8.6.1 Property Attributes has this to say about [[Writable]]
:
If false, attempts by ECMAScript code to change the property’s [[Value]] attribute using [[Put]] will not succeed.
Upvotes: 0
Reputation: 49919
From MSDN
Some more info here: http://msdn.microsoft.com/en-us/library/f5s9ycex(v=vs.94).aspx
All intrinsic JavaScript objects have a prototype property that is read-only. Properties and methods may be added to the prototype, but the object may not be assigned a different prototype. However, user-defined objects may be assigned a new prototype. The method and property lists for each intrinsic object in this language reference indicate which ones are part of the object's prototype, and which are not.
From the specification
Some more info here: http://www.ecma-international.org/ecma-262/5.1/#sec-15.2.3.1
15.2.3.1 Object.prototype
The initial value of Object.prototype is the standard built-in Object prototype object (15.2.4).
This property has the attributes {[[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
Upvotes: 2