javascript 상속


javascript 상속

function Rectangle(w, h) { var width = w; var height = h; this.getWidth = function() { return width; }; this.getHeight = function() { return height; }; this.setWidth = function(value) { if(value < 0) { throw '길이는 음수일 수 없습니다.'; } else { width = value; } }; this.setHeight = function(value) { if(value < 0) { throw '높이는 음수일 수 없습니다.'; } else { height = value; } }; } Rectangle.prototype.getArea = function() { return this.getWidth() * this.getHeight(); }; function Square(length) { this.base = Rectangle...


#IT·컴퓨터

원문링크 : javascript 상속