zoukankan      html  css  js  c++  java
  • 原型链 继承

            function F1() {}
            F1.prototype.sayHello = function(){
                alert("I'm a superman.");
            }
    
            function f2(skill){
                this.skill = skill;
            }
            f2.prototype = new F1();
    
            var david = new f2("fly");
            david.sayHello();

     继承

    function Person(name, age){
        this.name = name;
        this.age = age;
    }
    Person.prototype.sayHello = function(){
        alert('hello');
    }
    
    function Tom(id){
        this.id = id;
    }
    Tom.prototype = new Person('tom', '12');
    var tom = new Tom('123456');


    tom.id;
    tom.sayHello();
  • 相关阅读:
    python
    C++的socket编程学习
    GooglePlay
    GooglePlay
    Admob
    cocos2dx
    cocos2dx
    cocos2dx
    cocos2dx
    浅谈白鹭Egret
  • 原文地址:https://www.cnblogs.com/heqhbk/p/4311606.html
Copyright © 2011-2022 走看看