var Car=function(type){
var status="stop",//这里为什么不能用“:”
light="off";//这里为什么不能用“:”
return{
type:type,
start:function(){
status="driving";
light="on";
},
stop:function(){
status="stop";
light="off";
},
getStatus:function(){
console.log(type +" is "+ status +" with light "+ light );
}
}
}
var audi=new Car("audi");
audi.start();
audi.getStatus();//audi is driving with light on
audi.stop();
audi.getStatus();//audi is stop with light off
HiFrontend
Tobey_滔
相关分类