function Person(idn, dep, nam, age, gen, aut) {
this.idn = idn; //IDNumber
this.dep = dep; //Department
this.nam = nam; //Name
this.age = age; //Age
this.gen = gen; //Gender
this.aut = aut;
} //Auto
function Car(make, modl, year, lice, colo, mile, ownr) {
this.make = make; //MakeOfTheCar
this.modl = modl; //ModelOfTheCar
this.year = year; //Year
this.lice = lice; //Licence
this.colo = colo; //ColorOfTheCar
this.mile = mile; //Mileage
this.ownr = ownr;
} //Owner
var p01 = new Person(3475, 1, 'Rand,McKinnon', 33, 'M', c01);
var p02 = new Person(7608, 2, 'Ken,Jones', 39, 'M', c02);
var p03 = new Person(1957, 3, 'Vladi,Orlov', 58, 'M', c03);
var c01 = new Car('Eagle', 'Talon,TSi', 1993, 'BP456H46', 'red', 201, p01);
var c02 = new Car('Nissan', '300,ZX', 'J001', 1992, 'blue', 244, p02);
var c03 = new Car('Toyota', 'Avalon,XLS', '6HPR64W', 2000, 'black', 118, p03);
document.write('Car:c03.make=', c03.make, '|', c03.colo, '|', c03.ownr.nam, '<br>');
document.write('Person:p03.idn=', p03.idn, '|', p03.nam, '|', p03.gen, '|', p03.aut, '<br>');
末參數(p03.aut):未定義
需要你的幫助來弄清楚如何使它發揮作用。
當你創建'Person'對象你'C'變量不會被初始化。 –
當你嘗試將'Car'對象傳遞給'new Person()'時,沒有'Car'對象存在,所以'undefined'應該是可以的。 –
ouch,如果有人擁有2輛車! – charlietfl