`

js oo

阅读更多

var RectAngle = function(width, height) {
    this.width = width;
    this.height = height;
};


RectAngle.prototype = {
    area : function() {
        alert("this is RectAngle.prototype.area() method");
        return this.width * this.height;
    }
};


// RectAngle.prototype.area = function() {
//    alert("this is RectAngle.prototype.area() method");
//    return this.width * this.height;
//}


var rectAngle = new RectAngle(8, 7);
alert(rectAngle.width);
alert(rectAngle.height);
alert(rectAngle.area());

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics