Function 的 prototype

来源:互联网 发布:p2p网络投资理财平台 编辑:程序博客网 时间:2024/04/29 04:13

Function.prototype.method = function(name, func) {
            this.prototype[name] = func;
            return this;
        }
        function f1() {
        }
        f1.method("a", function(k) { alert(k+" "+this.b) }).method("b", "hello");
    new f1().a(1);

原创粉丝点击