function Dealership = function(){
this.car1="Honda";
this.car2="Chevy";
this.car3="Toyota";
this.carList=[this.car1,this.car2,this.car3];
};
var tomsauto = new Dealership();
tomsauto.car2="Subaru";
console.log(tomsauto.carList); //returns honda chevy toyota
我对数组的处理方式感到困惑。它是静态的,仅保留实例化时的变量值,还是当我改变tom.car1时,"this.car1"会跟着改变?
carList
是由值填充而不是引用。 - Teemu