Java代码  -  
 -  
 -   
 -    
 -   
 - function createCar(color,doors,mpg){  
 -     var tempCar = new Object;  
 -     tempCar.color = color;  
 -     tempCar.doors = doors;  
 -     tempCar.mpg = mpg;  
 -     tempCar.showCar = function(){  
 -         alert(this.color + " " + this.doors);  
 -     }  
 -     return tempCar;  
 - }   
 -   
 -  
 -  
 -   
 - function Car(color,doors,mpg){  
 -     this.color = color;  
 -     this.doors = doors;  
 -     this.mpg = mpg;  
 -     this.showCar = function(){  
 -         alert(this.color);  
 -     };  
 - }    
 -  
 -  
 -   
 - function Car(color,doors,mpg){  
 -     this.color = color;  
 -     this.doors = doors;  
 -     this.mpg = mpg;  
 -     this.drivers = new Array("nomad","angel");  
 - }  
 -   
 - Car.prototype.showCar3 = function(){  
 -     alert(this.color);  
 - };   
 -   
 -  
 -  
 -   
 - function Car(sColor, iDoors, iMpg) {  
 -     this.color = sColor;  
 -     this.doors = iDoors;  
 -     this.mpg = iMpg;  
 -     this.drivers = new Array("Mike", "Sue");  
 - }  
 -   
 - Car.prototype.showColor = function () {  
 -     alert(this.color);  
 - };    
 -  
 -  
 -   
 - function Car(sColor, iDoors, iMpg) {  
 -     this.color = sColor;  
 -     this.doors = iDoors;  
 -     this.mpg = iMpg;  
 -     this.drivers = new Array("Mike", "Sue");  
 -   
 -     if (typeof Car._initialized == "undefined") {  
 -   
 -         Car.prototype.showColor = function () {  
 -             alert(this.color);  
 -         };  
 -   
 -         Car._initialized = true;  
 -     }  
 - } 
  
		 
		
	 
	  
	 
	
				
			  |