zoukankan      html  css  js  c++  java
  • prototype exercise

    <html>
    <head>
    </head>
    <body>
    <div style="float:left;">
        <div id="div1" style="100px;height:100px;background-color:white;">
        </div>
        <div id="div2" style="100px;height:100px;background-color:white;">
        </div>
    </div>
    <div id="div3" style="100px;height:200px;background-color:white;float:left;">
    </div>
    <div id="div4" style="100px;height:200px;background-color:white;float:left;">
    </div>
    </body>
    <script type="text/javascript">
    /*function Person(name,age,job){
        this.name = name;
        this.age = age;
        this.job = job;
    }
    function Man(height,weight){
        this.height = height;
        this.weight = weight;
        this.name = 'aaa';
        Person.call(this,'Jean',100,'dev');
    }
    var m = new Man(100,100);*/
    function object(o){
        function F(){};
        F.prototype = o;
        return new F();
    }
    function inheritPrototype(subType, superType){
        var p = object(superType.prototype);
        p.constructor = subType;
        subType.prototype = p;
    }
    function SuperType(name){
        this.name=name;
        this.colors = ["red","blue","green"];
        this.sayColor = function (){
            alert(this.colors);
        };
    }
    SuperType.prototype.sayName = function(){
        alert(this.name);
    };
    inheritPrototype(SubType, SuperType);
    
    function SubType(name,age){
        SuperType.call(this,name);
        this.age = age;
    }
    
    //SubType.prototype = new SuperType("Ge");
    
    SubType.prototype.sayAge = function(){
        alert(this.age);
    };
    var i1 = new SubType("Jean",24);
    </script>
    </html>
  • 相关阅读:
    常吃二十种降血脂食物,三高不再缠身
    员工能力要从“人海战术”转向“精兵强将”
    企业家必备的4项核心能力
    优秀管理者在哪些方面超乎常人
    高血压 降压方法
    教育视频
    吉他和弦 学习
    spoj 375 QTREE
    hihocoder #1260 : String Problem I
    codeforces 282E. Sausage Maximization Trie
  • 原文地址:https://www.cnblogs.com/JingG/p/3090692.html
Copyright © 2011-2022 走看看