我有Director()函數。我用Director()構造函數創建了2個實例AlfredH和JohnD。我沒有寫出原型對象。構造函數和原型的值在寫完原型對象後發生了變化。爲什麼?
function Director(){
this.genre = "Thriller";
}
var AlfredH = new Director();
var JohnD = new Director();
如果我檢查JohnD.constructor的值;和JohnD.constructor.prototype;我分別得到導演()和對象()。
但是,如果我添加像下面特性原型處長(對象):
function Director(){
this.genre = "Thriller";
}
Director.prototype = {
noir: true
};
var AlfredH = new Director();
var JohnD = new Director();
,如果我檢查JohnD.constructor的值;和JohnD.constructor.prototype;我分別得到Object()和Object()。誰能解釋這種行爲?並且可以將其擴展爲JohnD.constructor.prototype.constructor的值;