`
pstinghua
  • 浏览: 24385 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

Extending Built-in Types

阅读更多

The Function.apply( ) method is missing in Microsoft Internet Explorer 4 and 5. This is a pretty
important function, and you may see code like this to replace it:

 

// IE 4 & 5 don't implement Function.apply( ).
// This workaround is based on code by Aaron Boodman.
if (!Function.prototype.apply) {
    // Invoke this function as a method of the specified object,
    // passing the specified parameters. We have to use eval( ) to do this
    Function.prototype.apply = function(object, parameters) {
        var f = this;                // The function to invoke
        var o = object || window;    // The object to invoke it on
        var args = parameters || []; // The arguments to pass
        // Temporarily make the function into a method of o
        // To do this we use a property name that is unlikely to exist
        o._$_apply_$_ = f;
     // We will use eval( ) to invoke the method. To do this we've got
     // to write the invocation as a string. First build the argument list.
     var stringArgs = [];
     for(var i = 0; i < args.length; i++)
         stringArgs[i] = "args[" + i + "]";
     // Concatenate the argument strings into a comma-separated list.
     var arglist = stringArgs.join(",");
     // Now build the entire method call string
     var methodcall = "o._$_apply_$_(" + arglist + ");";
     // Use the eval( ) function to make the methodcall
     var result = eval(methodcall);
     // Unbind the function from the object
     delete o._$_apply_$_;
     // And return the result
     return result;
  };
}
 
分享到:
评论

相关推荐

    HPL: Vol. IV: Functional and Logic Programming Languages

    2.14.1. The list Built-in Function 2.14.2. Backquote 2.15. Property Lists 2.16. Keymaps 2.17. Editing Lisp 2.18. Help 2.19. Debugging 2.19.1. The Built-in Debugger 2.19.2. Edebug 2.20. ...

    Python库参考手册.pdf

    It also documents the standard types of the language and its built-in functions and exceptions, many of which are not or incompletely documented in the Reference Manual. 本参考手册罗列并说明了...

    Python参考手册

    It also documents the standard types of the language and its built-in functions and exceptions, many of which are not or incompletely documented in the Reference Manual. 本参考手册罗列并说明了Python ...

    Sap Ruby Ajax

    Ruby on Rails provides built-in AJAX functionality through its API over Prototype and Scriptaculous. Let's explore how this integration is implemented using a simple example of locking and unlocking ...

    Lerner -- Python Workout. 50 Essential Exercises -- 2020.pdf

    - Using the `sum()` built-in function. - Handling exceptions for non-numeric inputs. 3. **Run Timing** - **Objective:** Measure the time taken to execute a specific piece of code. - **Key ...

    NS by examples.doc

    NS provides several built-in utilities, such as nsnam, which converts trace files into animations, and tcpprobe, which generates synthetic TCP traffic for testing purposes. These utilities assist in ...

    Prentice.Hall.C++.GUI.Programming.with.Qt.4.2nd.Edition.2008.chm

    Built-in Widget and Dialog Classes Chapter 3. Creating Main Windows Subclassing QMainWindow Creating Menus and Toolbars Setting Up the Status Bar Implementing the File Menu Using Dialogs ...

    ROR books 经典教程 入门 提高

    - **Chapter 22 Built-in Classes**(内置类):详细介绍 Ruby 内置的各种类及其用途。 - **Chapter 23 Built-in Modules**(内置模块):列举并解释 Ruby 中预定义的模块。 - **Chapter 24 Standard Library**...

    python3.6.5参考手册 chm

    What’s New in Python What’s New In Python 3.6 Summary – Release highlights New Features PEP 498: Formatted string literals PEP 526: Syntax for variable annotations PEP 515: Underscores in ...

    Addison.Wesley.The.Java.Programming.Language.4th.Edition.Aug.2005.chm

    handling capabilities, and the use of assertions to validate the expected behavior of code. &lt;br&gt;Chapter 13Strings and Regular Expressionsdescribes the built-in language and runtime support for ...

    Sams.Publishing.Python.Essential.Reference.3rd.Edition.2006.pdf

    2. **Built-in Functions and Exceptions**(内置函数与异常) - Python提供的各种内置函数,如len()、print()等。 - 异常处理机制及常见异常类型。 3. **Python Runtime Services**(Python运行时服务) - ...

    salesforce dev 501 Notes

    - **Standard Components**: These are pre-built UI elements like text boxes, buttons, picklists, etc., which can be easily customized using attributes. - **Layout Components**: Components like panels, ...

    Seamless R and C++ Integration

    Conversion from C++ to R and back is driven by the templates Rcpp::wrap and Rcpp::as which are highly flexible and extensible, as documented in the Rcpp-extending vignette. Rcpp also provides Rcpp ...

    spring-boot-reference.pdf

    57.1. Extending Configuration 57.2. Programmatically 58. Cloud Foundry Support 58.1. Disabling Extended Cloud Foundry Actuator Support 58.2. Cloud Foundry Self-signed Certificates 58.3. Custom context...

    最新版的DebuggingWithGDB7.05-2010

    2 Getting In and Out of gdb . . . . . . . . . . . . . . . . . . . 11 2.1 Invoking gdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.1 Choosing ...

    Digging into WordPress.pdf

    2.2.1 OK, I’m In. Now What? .............................................25 2.2.2 Just Publish Something! .............................................................25 2.2.3 Go Look At It! ...........

    spring-framework-reference-4.1.2

    3. New Features and Enhancements in Spring Framework 4.0 ............................................ 17 3.1. Improved Getting Started Experience .........................................................

    spring-framework-reference4.1.4

    3. New Features and Enhancements in Spring Framework 4.0 ............................................ 17 3.1. Improved Getting Started Experience .........................................................

Global site tag (gtag.js) - Google Analytics