Javascript&Jquery
생성자함수 Rectangle 선언
알 수 없는 사용자
2012. 1. 23. 17:54
//생성자함수를 선언
function Rectangle(width,height) {
this.width=width;
this.height=height;
}
Rectangle.prototype.getArea=function(){
return this.width*this.height;
};
//변수를 선언
var rectangle =new Rectangle(5,7);
//출력
alert('AREA:'+rectangle.getArea());