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

    面向对象

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <title>JS面向对象</title>
    </head>
    <body>
        <script>
            //var person = {
            //    name: "jack",
            //    age: 30,
            //    eat: function () {
            //        alert("can eat");
            //    }
            //}
            //alert(person.name);
        </script>
        <script>
            //function Person() {
    
            //}
            //Person.prototype = {
            //    name: "jack",
            //    age: 30,
            //    eat: function () {
            //        alert("can eat");
            //    }
            //}
            //var p = new Person();
            //p.eat();
        </script>
        <script>
            //function People(name) {
            //    this._name = name;
            //}
            //People.prototype.say = function () {
            //    alert("peo-hello" + this._name);
            //}
            //function Student(name) {
            //    this._name = name;
            //}
            //Student.prototype = new People();
            //var superSay = Student.prototype.say;
            //Student.prototype.say = function () {
            //    superSay.call();
            //    alert("stu-hello" + this._name);
            //}
            //var s = new Student("jack");
            //s.say();
    
        </script>
        <script>
            //(function () {
            //    var n = "n";
            //    function People(name) {
            //        this._name = name;
            //    }
            //    People.prototype.say = function () {
            //        alert("peo-hello " + this._name + " " + n);
            //    }
            //    window.People = People;
            //}());
            //(function () {
            //    function Student(name) {
            //        this._name = name;
            //    }
            //    Student.prototype = new People();
            //    var superSay = Student.prototype.say;
            //    Student.prototype.say = function () {
            //        superSay.call(this);
            //        alert("stu-hello " + this._name);
            //    }
            //    window.Student = Student;
            //}())
            //var s = new Student("jack");
            //s.say();
        </script>
        <script>
            //function Person(name) {
            //     var _this = {};
            //     _this._name = name;
            //     _this.sayHello = function () {
            //         alert("p hello " + _this._name);
            //     }
            //     return _this;
            // }
            // function Teacher(name) {
            //     var _this = Person(name);
            //     var surperSay = _this.sayHello;
            //     _this.sayHello = function () {
            //         surperSay.call(_this);
            //         alert("t hello " + _this._name);
            //     }
            //     return _this;
            // }
            // var t = Teacher("jack");
            // t.sayHello();
        </script>
        <script>
            (function () {
                var n = "n";
                function Person(name) {
                    var _this = {};
                    _this._name = name;
                    _this.sayHello = function () {
                        alert("p hello " + _this._name + " " + n);
                    }
                    return _this;
                }
                window.Person = Person;
            })
            function Teacher(name) {
                var _this = window.Person(name);
                var surperSay = _this.sayHello;
                _this.sayHello = function () {
                    surperSay.call(_this);
                    alert("t hello " + _this._name);
                }
                return _this;
            }
            var t = Teacher("jack");
            t.sayHello();
        </script>
    </body>
    </html>
  • 相关阅读:
    oracleDBA-D4
    oracleDBA-D3
    oracleDBA-D2
    大数据架构学习记录
    UBUNTU 安装最新版 nodejs
    datax 单条记录超过大小限制,当前限制为:67108864
    将anaconda中已存在的虚拟环境增加到jupyterlab
    jupyter 启动python3 内核 总是出现错误 ImportError: cannot import name 'create_prompt_application'
    CDH 本地hadoop支持读写 AWS S3a
    hadoop 集群集成jupyterhub 出现的问题
  • 原文地址:https://www.cnblogs.com/kikyoqiang/p/11285183.html
Copyright © 2011-2022 走看看