In continuation of this question, what is prototype.constructor for?
I thought that by simply doing:
new some_object()
that the function object became a constructor. I don't understand why you would need to set it in this manner.
some_object.prototype.constructor = some_object;
Suppose class A inherit B using the following:
A.prototype = new B();
After this A.prototype.constructor == B. So instances of A have a constructor from B. It's a good practice to reset a constructor after the assignment.
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