原型的动态性

时间:2015-12-30 11:29:56   收藏:0   阅读:134

 

这是对《高级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);

 

原文:http://www.cnblogs.com/masita/p/5088005.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!