i구야 2015. 2. 24. 15:44

<html>
<body>
 <script>
 function Car(a,b){
 var color=a;
this.speed=b;
this.getColor=function(){
 return color;
}
 }
 Car.prototype.getSpeed=function(){
  return this.speed;
 }
 var car=new Car("red",100);
 document.write(car.getColor()+"<br>"); // red
 document.write(car.getSpeed()); // 100
 </script>
</body>
</html>