zoukankan      html  css  js  c++  java
  • js 面向对象2

    面向对象的特征是封装 继承 多态 封装 

    function animal() {
        var name;

        this.eat = function eat()
        { return 0; }
    }

    //继承
    function cat() {
    }

    cat.prototype = new animal();

    function cat() {
        this.eat = function eat()
        { return 0; }
    }

    cat.prototype = new animal();

    function dog() {
        this.eat = function eat()
        { return 0; }
    }

    dog.prototype = new animal();

    //多态
    var cat1 = new cat(); cat1.name = "jiafei";

    var dog1 = new dog(); dog1.name = "odi";

    var list = [cat1, dog1];
  • 相关阅读:
    tzselect
    tzfile
    ttytype
    tty
    TRUNCATE
    true
    troff
    touch
    Open vSwitch
    Web 在线文件管理器学习笔记与总结(5)修改文件内容
  • 原文地址:https://www.cnblogs.com/frog2008/p/2328065.html
Copyright © 2011-2022 走看看