function MyObject(){}
Array.prototype={};
MyObject.prototype={};
var a=new Array();
var b=new MyObject();
alert(a.constructor==Array);//true
alert(b.constructor==MyObject);//false
Array.prototype
is a non-writable property.
As such, your assignment:
Array.prototype = {}
...doesn't succeed, and so its .constructor
property hasn't changed.
15.4.3.1 Array.prototype
The initial value of
Array.prototype
is the Array prototype object (15.4.4).This property has the attributes
{ [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }
...whereas with your custom constructor, you have the ability to assign a different prototype object, so you've overwritten the original which had reference to the constructor via .constructor
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With