// 原型构造函数
function Rectangle(x,y){
this.x = x;
this.y = y;
}
Rectangle.prototype.perimeter = function(){
return 2*(this.x + this.y);
}
var rect = new Rectangle(1,2);
console.log(rect.perimeter());
转载于:https://my.oschina.net/newgoup/blog/699562