<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>
'개발하자 > 자바스크립트' 카테고리의 다른 글
prototype 으로 메서드 생성해서 공용으로 사용하기 (0) | 2015.02.24 |
---|---|
Car.prototype.getSpeed (0) | 2015.02.24 |
StringBuffer (0) | 2015.02.24 |
sort (0) | 2015.02.24 |
buffer.join(""); (0) | 2015.02.24 |