Ich möchte ein Objekt A erstellen, so dass ich schreiben wie folgt aus:Was bedeutet "A.fn.A.init {}"?
A = function() {
}
A.prototype = {
init: function() {
console.log(this);
}
}
Das Ergebnis new A.prototype.init()
ist A.init {}
.
Wenn ich erstellen einen Alias für A.prototype wie folgt aus:
A = function() {
}
A.as = A.prototype = {
init: function() {
console.log(this);
}
}
Das Ergebnis A.as.A.init {}
statt A.init {}
entpuppte.
Warum? Wie funktioniert this
?
Was ist das erwartete Ergebnis? – guest271314
"* Das Ergebnis von' new A.prototype.init() '*" Tu das nicht. Erstellen Sie 'neue A' -Instanzen, wenn Sie das möchten, und legen Sie' init'-Methoden ab. – Bergi