码迷,mamicode.com
首页 > Web开发 > 详细

js练习 原型

时间:2016-04-01 17:43:24      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:

        //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();

js练习 原型

标签:

原文地址:http://www.cnblogs.com/qook/p/5345431.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!