/**
 * @class Function
 * These functions are available on every Function object (any JavaScript function).
 */
Ext.apply(Function.prototype, {
     /**
     * Creates an interceptor function. The passed fcn is called before the original one. If it returns false,
     * the original one is not called. The resulting function returns the results of the original function.
     * The passed fcn is called with the parameters of the original function. Example usage:
     * <pre><code>
var sayHi = function(name){
    alert('Hi, ' + name);
}sayHi('Fred'); // alerts "Hi, Fred"// create a new function that validates input without
// directly modifying the original function:
var sayHiToFriend = sayHi.createInterceptor(function(name){
    return name == 'Brian';
});sayHiToFriend('Fred');  // no alert
sayHiToFriend('Brian'); // alerts "Hi, Brian"
</code></pre>
     * @param {Function} fcn The function to call before the original
     * @param {Object} scope (optional) The scope of the passed fcn (Defaults to scope of original function or window)
     * @return {Function} The new function
     */
    createInterceptor : function(fcn, scope){
        var method = this;
        return !Ext.isFunction(fcn) ?
                this :
                function() {
                    var me = this,
                        args = arguments;
                    fcn.target = me;
                    fcn.method = method;
                    return (fcn.apply(scope || me || window, args) !== false) ?
                            method.apply(me || window, args) :
                            null;
                };
    },     /**
     * Creates a callback that passes arguments[0], arguments[1], arguments[2], ...
     * Call directly on any function. Example: <code>myFunction.createCallback(arg1, arg2)</code>
     * Will create a function that is bound to those 2 args. <b>If a specific scope is required in the
     * callback, use {@link #createDelegate} instead.</b> The function returned by createCallback always
     * executes in the window scope.
     * <p>This method is required when you want to pass arguments to a callback function.  If no arguments
     * are needed, you can simply pass a reference to the function as a callback (e.g., callback: myFn).
     * However, if you tried to pass a function with arguments (e.g., callback: myFn(arg1, arg2)) the function
     * would simply execute immediately when the code is parsed. Example usage:
     * <pre><code>
var sayHi = function(name){
    alert('Hi, ' + name);
}// clicking the button alerts "Hi, Fred"
new Ext.Button({
    text: 'Say Hi',
    renderTo: Ext.getBody(),
    handler: sayHi.createCallback('Fred')
});
</code></pre>
     * @return {Function} The new function
    */
    createCallback : function(/*args...*/){
        // make args available, in function below
        var args = arguments,
            method = this;
        return function() {
            return method.apply(window, args);
        };
    },    /**
     * Creates a delegate (callback) that sets the scope to obj.
     * Call directly on any function. Example: <code>this.myFunction.createDelegate(this, [arg1, arg2])</code>
     * Will create a function that is automatically scoped to obj so that the <tt>this</tt> variable inside the
     * callback points to obj. Example usage:
     * <pre><code>
var sayHi = function(name){
    // Note this use of "this.text" here.  This function expects to
    // execute within a scope that contains a text property.  In this
    // example, the "this" variable is pointing to the btn object that
    // was passed in createDelegate below.
    alert('Hi, ' + name + '. You clicked the "' + this.text + '" button.');
}var btn = new Ext.Button({
    text: 'Say Hi',
    renderTo: Ext.getBody()
});// This callback will execute in the scope of the
// button instance. Clicking the button alerts
// "Hi, Fred. You clicked the "Say Hi" button."
btn.on('click', sayHi.createDelegate(btn, ['Fred']));
</code></pre>
     * @param {Object} obj (optional) The object for which the scope is set
     * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
     * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
     *                                             if a number the args are inserted at the specified position
     * @return {Function} The new function
     */
    createDelegate : function(obj, args, appendArgs){
        var method = this;
        return function() {
            var callArgs = args || arguments;
            if (appendArgs === true){
                callArgs = Array.prototype.slice.call(arguments, 0);
                callArgs = callArgs.concat(args);
            }else if (typeof appendArgs == "number"){
                callArgs = Array.prototype.slice.call(arguments, 0); // copy arguments first
                var applyArgs = [appendArgs, 0].concat(args); // create method call params
                Array.prototype.splice.apply(callArgs, applyArgs); // splice them in
            }
            return method.apply(obj || window, callArgs);
        };
    },    /**
     * Calls this function after the number of millseconds specified, optionally in a specific scope. Example usage:
     * <pre><code>
var sayHi = function(name){
    alert('Hi, ' + name);
}// executes immediately:
sayHi('Fred');// executes after 2 seconds:
sayHi.defer(2000, this, ['Fred']);// this syntax is sometimes useful for deferring
// execution of an anonymous function:
(function(){
    alert('Anonymous');
}).defer(100);
</code></pre>
     * @param {Number} millis The number of milliseconds for the setTimeout call (if 0 the function is executed immediately)
     * @param {Object} obj (optional) The object for which the scope is set
     * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
     * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
     *                                             if a number the args are inserted at the specified position
     * @return {Number} The timeout id that can be used with clearTimeout
     */
    defer : function(millis, obj, args, appendArgs){
        var fn = this.createDelegate(obj, args, appendArgs);
        if(millis){
            return setTimeout(fn, millis);
        }
        fn();
        return 0;
    }
});

解决方案 »

  1.   

    Function.prototype什么意思,Function指的是???
      

  2.   

    就是Function对象的原型.
    Function对象是JS的内置对象.
    你可以查下JS的文档.
      

  3.   

    Function是对象
    Function.protoype是对象的原型
      

  4.   

    Function是对象 用的太少了,与Function有什么区别啊
    可否举个Function的事例
      

  5.   

    function定义方法的对象
    var a=function(){};
      

  6.   

    建议LZ先把JS文档过一遍,再尝试去看EXT的源码.
    不然就是"未学走,先学跑."
      

  7.   

    function定义方法的对象
    var a=function(){}; 
    即是Function对象
    那么有function就OK了
    Function对象不是多余么。
      

  8.   

    js中Function是一种数据类型。Function.prototype是函数类型的原型。
      

  9.   

    var a=new Function()  似乎可以这样定义吧。然后Function.prototype 原型,有什么用处呢?我觉得继承时就有用了,原型继承,父类变了,子类都变化,---------------------=======不知道有没有说错。现在忘得比较多了,
      

  10.   

    function 方法名(参数1,参数2){
       代码;
    }
    相当于方法名 = function (参数1,参数2){
       代码;
    }
    相当于方法名 = new Function(参数1,参数2,"代码;");
      

  11.   

    var a = function(){}的确是一个Function对象。
    但是var a = new Function();同样是一个Function对象.
      

  12.   


    这样解释:所有js函数都是由 Function 类定义而来。
    例:
    var msgHi = new Function("sName","sMsg","alert('Hello '+sName+','+sMsg);");
    等同于:
    function msgHi() {
      alert('Hello '+sName+','+sMsg);
    }
      

  13.   

    var msgHi = new Function("sName","sMsg","alert('Hello '+sName+','+sMsg);"); //等同于: 
    function msgHi() { 
      alert('Hello '+sName+','+sMsg); 
    }
      

  14.   

    到riccc的blog去看
    http://www.cnblogs.com/RicCC/archive/2008/02/15/JavaScript-Object-Model-Execution-Model.html
    作者写得非常好,特别是这张对象模型图,非常好,非常好,包含了很多东西了。
      

  15.   

    http://hi.baidu.com/xiaolei1982/blog/item/a941e43fcfa147c07c1e7165.html
      

  16.   

    函数:原型每一个构造函数都有一个属性叫做原型(prototype,下面都不再翻译,使用其原文)。这个属性非常有用:为一个特定类声明通用的变量或者函数。prototype的定义你不需要显式地声明一个prototype属性,因为在每一个构造函数中都有它的存在。你可以看看下面的例子:Example PT1 
    function Test()
    {
    }
    alert(Test.prototype); // 输出 "Object"
    给prototype添加属性就如你在上面所看到的,prototype是一个对象,因此,你能够给它添加属性。你添加给prototype的属性将会成为使用这个构造函数创建的对象的通用属性。例如,我下面有一个数据类型Fish,我想让所有的鱼都有这些属性:livesIn="water"和price=20;为了实现这个,我可以给构造函数Fish的prototype添加那些属性。
      

  17.   


    一句话:function是方法.. Function是对象.
      

  18.   

    Function是特殊的Object ,Function.prototype是它的原型链function 可以用来声明 方法或者对象每个function都是Function类型的new Function("func"); 和 function func(){};是一样的 ,不过一般都实用后者来创建方法或对象
      

  19.   

    http://www.javaeye.com/topic/288808
    prototype(原型)--在这里会反复提到"原型对象"和"原型属性",注意区分这两个概念.
    在javascript中,每个对象都有一个prototype属性,这个属性指向了一个prototype对象.
    上面我们提到了用new来创建一个对象的过程,事实上在这个过程中,当创建了空对象后,new会接着操作刚生成的这个对象的prototype属性.
    每个方法都有一个prototype属性(因为方法本身也是对象),new操作符生成的新对象的prototype属性值和构造方法的prototype属性值是一致的.构造方
    法的prototype属性指向了一个prototype对象,这个prototype对象初始只有一个属性constructor,而这个constructor属性又指向了prototype属性所在的方
    法(In the previous section, I showed that the new operator creates a new, empty object and then invokes a constructor 
    function as a method of that object. This is not the complete story, however. After creating the empty object, 
    new sets the prototype of that object. The prototype of an object is the value of the prototype property of its 
    constructor function. All functions have a prototype property that is automatically created and initialized when 
    the function is defined. The initial value of the prototype property is an object with a single property. This property 
    is named constructor and refers back to the constructor function with which the prototype is associated. this is why every 
    object has a constructor property. Any properties you add to this prototype object will appear to be properties of 
    objects initialized by the constructor. -----section9.2)
      

  20.   

    相关文章:http://www.scriptlover.com/post/536
      

  21.   

    javascript是基于对象的语言啊,和Java上样也是有构造函数的,prototype就类似于Java的的类的属性啊
      

  22.   

    是JS被封装拉,LZ懂JS,也很快会理解的
      

  23.   

    Ext的源码?你连这个都不知道,我建议就不要看EXT源码了。 对象,prototype, closure 这些要很熟,才好去研究这些高手的源码。否则一头雾水。
      

  24.   

    Function.prototype相当于构造函数 
    js里面的 构造函数就是类 
    Ext.apply(Function.prototype, {})
    就是说用Ext是一个类 传递过去的参数是json对象 在Function.prototype内部运行Ext({..}})
    是扩展这个构造函数 相当于继承
      

  25.   

    script 值得学习,ajax现在也很好用
      

  26.   

    JavaScript的类和方法:function Node(id, pid, name){
        this.id=id;
        this.pid=pid;
        this.name=name;
    }//类中方法的定义:
    //类名.prototype.方法名 = function (参数){}
     
    //例如:
    Node.prototype.addnew = function (id,pid,name){
        ...
        var node = new Node(id,pid,name);
        this.add(node);
        ...
    }//也可以写成:
    //this.方法名 = function (参数){}
    //例如:
    this.addnew = function (id,pid,name){
        ...
        var node = new Node(id,pid,name);
        this.add(node);
        ...
    }
      

  27.   

    function 是定义一个函数,可以调用的
      

  28.   

    Function是对象 
    Function.protoype是对象的原型
      

  29.   

    function定义方法的对象 
    var a=function(){}; 
      

  30.   

    Function是类
    var myfun = new Function("param1", "param2", "alert('param1 + param2 = '+ param1 + param2)");
    myfun();protoype 是类的原型对象
      

  31.   

    想不出来,我看直接Math.max(a,b)好了,我放弃。
      

  32.   

    建议去看看  淘宝的那群前端的网站,blog很好