Ich schaffe diese Code-Block in javascript:
function Shape() {}
Shape.prototype.name = Shape;
Shape.prototype.toString = function() {
result = [];
if(this.constructor.uber) {
result[result.length] = this.constructor.uber.toString();
}
result[result.length] = this.name;
return result.join(', ');
}
function twoDShape() {};
twoDShape.prototype = new Shape();
twoDShape.prototype.constructor = twoDShape;
twoDShape.uber = twoDShape.prototype;
twoDShape.name = twoD Shape;
var a = new twoDShape();
console.log(a.toString());
Ich weiß nicht, warum, aber wenn ich es laufen, firefox ist einfrieren. Ich habe Stunden versucht, es herauszufinden. Und meine Vermutung ist, sollte es eine Endlosschleifen in meinem Code und es lebt irgendwo in der, wenn die Bedingung, aber ich fand es nicht aus. Könnte mir jemand aus diesen Kopfschmerzen helfen. Vielen Dank!