前端学习笔记202309学习笔记第九十三天-面向对象8

function Test(a,b){
    this.a=a
    this.b=b
}
Test.prototype={
    plus:function(){
        console.log(this)
        return this.a+this.b
    }
}
const test1=new Test(1,2)
console.log(test1.plus())

运行结果

 

posted @ 2023-09-21 10:43  前端导师歌谣  阅读(9)  评论(0)    收藏  举报  来源