zoukankan      html  css  js  c++  java
  • js练习 原型

            //var a = {
            //    fun: function a() {
            //        test = 0;
            //        alert(this);
            //        b();
            //        function b() {
            //            alert(this);
            //            var v = 0;
            //        }
            //    }
            //};
            //a.fun();

            Function.prototype.method = function (name, func) {
                //alert(this);
                this.prototype[name] = func;
                return this;
            };
            var test = function () {
                this.value = 0;
                alert('test');
            }
            test.prototype.method1 = function () {
                alert('method1');
            };
            
            //var method1= Function.method("method1", function () {
            //    alert('method1');
            //    alert(this);
            //    method2();
            //    function method2() {
            //        alert(this);
            //    }
            //})
            //test.method1();


            var test2 = function () {

            };
            test2.prototype = new test();
            var test2Instance = new test2();
            alert(test2Instance.value);

            //test.method1();

            //alert('1');
            //Function.method1();
            //method1.method1();

  • 相关阅读:
    Ajax组件(wagang版)
    动画组件(wagang版)之基础篇:跳帧与延时
    Ajax组件(wagang版)之无依赖化
    ✍23 postgresql批量删除表
    ✍20 samba共享服务
    ✍16 asyncio异步IO
    ✍19 Tensonfow(GPU)使用
    ✍25 mysqlclient 安装(linux,mac)
    ✍17 aiohttp模块的使用
    ✍18 Linnux上安装node.js
  • 原文地址:https://www.cnblogs.com/qook/p/5345431.html
Copyright © 2011-2022 走看看