您当前的位置: 首页 > 

壹小俊

暂无认证

  • 0浏览

    0关注

    885博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

第六课--继承prototype

壹小俊 发布时间:2019-09-16 10:40:58 ,浏览量:0

创建好的对象,我们是不能随便添加方法或者属性的,但是有时候是迫不得已的修改他人的对象但是还不能破坏其对象的内容。这个时候,我们就用到了继承。




    
    
    
    Document


    
    function Person(first, last, age, eyecolor) {
        this.firstName = first;
        this.lastName = last;
        this.age = age;
        this.eyeColor = eyecolor;
    }    
    Person.prototype.nationality = "English";    
    Person.prototype.name = function() {
        return this.firstName + " " + this.lastName;
    };   
    var  demo = new Person('wenjun','huo',12,'嘻哈')    
    console.log(demo.nationality)
    console.log(demo.name())
    

 

关注
打赏
1664335782
查看更多评论
立即登录/注册

微信扫码登录

0.0446s