Skip the following snippet of code 1 and see what happens in the JS console:
My questions are about the last line in the snippet:
- Why is it
F.prototype.method;changed? - How to override
Fcustom.prototype.methodso as not to change F.prototype.method?
Note. I use jQuery and underscore to extend the function.
1 Excerpt from the test code:
var F = function () {};
F.prototype.method = function () {
}
F.prototype.method;
Fcustom = $.extend(true, F, {});
_.extend(Fcustom.prototype, {
method: function () {
}
});
Fcustom.prototype.method;
F.prototype.method;
source
share