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

    1. 面向对象

    <!DOCTYPE html>
    <html>
    <head lang="en">
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <p id="pTime"></p>
        <script src="myjavascript.js">
        </script>
    </body>
    </html>
    /**
     * Created by Administrator on 2015/2/13.
     */
    var person = {
        name:"mirror",
        age:30,
        eat:function(){
            alert("吃货")
        }
    }
    alert(person.name);

    2. 继承

    /**
     * Created by Administrator on 2015/2/13.
     */
    function Person(){}
    function Student(){}
    
    Person.prototype.say = function () {
        alert("hello");
    }
    
    Student.prototype = new Person();
    
    var s = new Student();
    
    s.say();

    3. 复写

    /**
     * Created by Administrator on 2015/2/13.
     */
    function Person(){}
    function Student(){}
    
    Person.prototype.say = function () {
        alert("hello");
    }
    
    Student.prototype = new Person();
    Student.prototype.say() = function() {
        alert("stu-hello");
    }
    
    var s = new Student();
    s.say();

    3. 面向对象例子

  • 相关阅读:
    文本数据清洗总结
    PyTorch
    PyTorch
    NLP
    TF
    TF
    TF
    cairosvg
    word2vec 实现 影评情感分析
    Gensim
  • 原文地址:https://www.cnblogs.com/iMirror/p/4289949.html
Copyright © 2011-2022 走看看