zoukankan      html  css  js  c++  java
  • 组合继承

    //父类
        function superClass(name){
            this.name = name;
            this.books = ['html','css','javascript'];
        }
        superClass.prototype.getName = function(){
            console.log(this.name);
        }
        //子类
        function subClass(name,time){
            superClass.call(this,name);
            this.time = time;
        }
        
        subClass.prototype = superClass.prototype;
        subClass.prototype.getTime = function(){
            console.log(this.time);
        }
        var s1 = new superClass();
        var s2 = new subClass('klkx',2018);
        s2.books.push('vue');
        console.log( s2 );
        s2.getName();
        console.log( s2.books );
        console.log( s1.books );
  • 相关阅读:
    团队冲刺第十天
    每日学习
    每日学习
    团队冲刺第九天
    每日学习
    2021.4.26
    2021.4.23
    2021.4.22
    2021.4.21
    2021.4.20
  • 原文地址:https://www.cnblogs.com/jokes/p/9590802.html
Copyright © 2011-2022 走看看