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

Posted 杜俊锋

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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>

以上是关于javascript 的类式继承(构造函数)的主要内容,如果未能解决你的问题,请参考以下文章