Answers (please read them below, their respective authors provided valuable insights):
Yes, this is expected behaviour.
it fails silently.
Not exactly. Or: Only in sloppy mode. If you "use strict" mode, you'll get an
Error { message: "Invalid assignment in strict mode", … }
on the line test4.answer = function() { return 0; };
it can be overloaded on the prototype of a subclass (test2), but not an instance of a subclass (test4)
This has nothing to do with instances vs. prototypes. What you didn't notice is that you're using different ways to create the overloading property:
Object.defineProperty
call just creates a new property, unless the object is non-extensibleYou can do the same for your instance:
Object.defineProperty(test4, "answer", {
value: function() { return 42; }
});