I wanted to dig in into the language specific construct "prototype" of javascript. And here is my learning purpose code:
var f = function() {};
f.ext = 1;
f.prototype.pext = 2;
When i debug this code now with firebug, i get the following:
Where does this infinite nesting come from? Let's begin from top (OK=unterstood):
f (OK)
- ext (OK)
- prototype (OK)
- pext (OK)
- constructor (I'm stuck at this point)
Whose constructor is that? And why do we have this infinte nesting?
Its simply because f === f.prototype.constructor
, those are the same and Firebug shows them as circular references.
The same as:
var a = {},
b = a;
a.b = b;
You will see infinite references here too.
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