javascript 的类式继承(构造函数)

<script type="text/javascript">   
//类式继承(构造函数)
var father = function(){
    this.age = 52;
    this.say =function(){
        alert('hello i am'+this.name+'and i am'+this.age+'years old')
    }
}
var child = function(){
    this.name = 'bill';
    father.call(this);
}
var man = new child();
man.say();



</script>

posted @ 2017-12-09 16:59  HaOnBaby  阅读(153)  评论(0)    收藏  举报