ho notato che il congelamento del prototipo di una funzione di costruzione ha avuto un effetto collaterale che, in fondo ha rotto costruttore concatenamento:javascript - Gli effetti collaterali di congelamento un prototipo costruttore
function A(x) {
this.x=x;
}
function B(x, y) {
A.call(this, x);
this.y=y;
}
B.prototype = new A();
Object.freeze(B.prototype);
b=new B(1,2)
// I expected b.x to be 1 here but it's undefined
Ecco un violino per dimostrare il problema:
http://jsfiddle.net/jhpxv20b/2/
c'è una buona ragione per cui bx è indefinito alla fine?
Se questo non è un bug, allora come mai x2 è 1 nel violino?
Sebbene la tua domanda non abbia esattamente lo stesso codice, [questa domanda] (http://stackoverflow.com/questions/19698533/creating-new-objects-from-frozen-parent-objects/19698581#19698581) spiega perché questo è il caso. –