What is wrong with example 4?
constructor of MyClass does not sit in MyClass.prototype. what a surprise that it does not get overriden...
I noticed that you are saying it is a bogus example. I just felt that unlike the other examples where it might look surprising to some the No.4 is just plain error.
Which makes sense once you know that instance.constructor is accessing an altered constuctor property from the prototype, but otherwise might be quite confusing.
You're right that it probably doesn't belong with the other examples. Hopefully JavaScript developers unaware of prototype.constructor might find it interesting.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
What is wrong with example 4?
constructor of
MyClassdoes not sit inMyClass.prototype. what a surprise that it does not get overriden...I noticed that you are saying it is a bogus example. I just felt that unlike the other examples where it might look surprising to some the No.4 is just plain error.
The confusing part is this:
Which makes sense once you know that
instance.constructoris accessing an alteredconstuctorproperty from the prototype, but otherwise might be quite confusing.You're right that it probably doesn't belong with the other examples. Hopefully JavaScript developers unaware of
prototype.constructormight find it interesting.