• js中的继承


    <script>
    //js中的继承
    function Animal(){
    this.kind = "animal";
    }
    Animal.prototype.type = "water";
    //绑定构造函数,原型中的属性和方法不会被继承。
    function Cat(Name,Color){
    this.Name = Name;
    this.Color = Color;
    Animal.apply(this.arguments);
    }
    var cat = new Cat("tom","watth");
    console.log(cat);
    //原型指向父类对象,继承父类中的所有属性和方法,包括原型中的内容
    function Animal(){
    this.kind = "animal";
    }
    Animal.prototype.type = "water";
    function Cat(name,Color){
    this.name = name;
    this.Color = Color;
    }
    Cat.prototype = new Animal();
    var cat = new Cat("tom","white");
    console.log(cat);
    </script>
  • 相关阅读:
    关于input()
    HDU 3746
    HDU 4335 Contest 4
    HDU 4418 高斯消元法求概率DP
    HDU 4339 Contest 4
    HDU 4334 Contest 4
    HDU 4333 Contest 4
    HDU 4332 Contest 4
    HDU 4035
    HDU 4336
  • 原文地址:https://www.cnblogs.com/wtdall/p/10754337.html
Copyright © 2020-2023  润新知