侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

原型构造函数

2024-05-15 星期三 / 0 评论 / 0 点赞 / 83 阅读 / 324 字

// 原型构造函数 function Rectangle(x,y){ this.x = x; this.y = y; } Rectangle.prototype.perimeter = fun

// 原型构造函数
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());

广告 广告

评论区