原型的动态性

 

这是对《高级3》的P156页,原型的动态性的理解

复制代码
function Person(){

    }

    var oldproto = Person.prototype;

    var friend = new Person();

    Person.prototype = {
        constructor: Person,
        name: "Nicholas",
        age: 29,
        job: "Software Engineer",
        sayName: function () {
            alert(this.name);
        }
    };


    console.log(oldproto);
    console.log(Person.prototype);
复制代码

 

posted @   马斯塔  阅读(143)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示