原型的动态性

 

这是对《高级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 @ 2015-12-30 10:34  马斯塔  阅读(143)  评论(0编辑  收藏  举报