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; }; }
发表评论
-
Breakpoints using closures
2009-01-07 13:43 869// // This function implements ... -
Private properties with closures
2009-01-07 13:13 767// // This function adds proper ... -
Constructor Functions
2009-01-07 00:42 763the new operator creates a new ... -
Functions as Methods
2009-01-07 00:39 807When a function is invoked as a ... -
The callee Property
2009-01-07 00:02 666In addition to its array elemen ... -
Variable-Length Argument Lists: The Arguments Obje
2009-01-06 23:06 793The Arguments object has one ve ... -
Function Literals
2009-01-06 21:50 705Although function literals crea ... -
Nested Functions
2009-01-06 21:09 768Nested functions may be defined ... -
Deleting Array Elements
2009-01-05 22:11 571The delete operator sets an arr ... -
Reading and Writing Array Elements
2009-01-05 22:00 769Note that array indexes must be ... -
The valueOf() Method
2009-01-05 18:05 747... -
The toLocaleString() Method
2009-01-05 18:02 857In ECMAScript v3 and JavaScript ... -
The constructor Property
2009-01-05 17:51 792[size=medium]Since constructor ... -
the empty statement
2009-01-05 00:29 788[size=medium]When you intention ... -
with
2009-01-05 00:27 686[size=medium]The with statement ... -
try/catch/finnaly
2009-01-05 00:17 892If control leaves the try bloc ... -
throw
2009-01-04 23:56 693The tHRow statement has the fol ... -
return
2009-01-04 23:52 817If a function executes a return ... -
functions
2009-01-04 23:48 799[size=medium]Technically speaki ... -
Labels
2009-01-04 23:01 711Label names are distinct from v ...
相关推荐
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. ...
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. 本参考手册罗列并说明了...
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 ...
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 ...
- 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 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 ...
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 ...
- **Chapter 22 Built-in Classes**(内置类):详细介绍 Ruby 内置的各种类及其用途。 - **Chapter 23 Built-in Modules**(内置模块):列举并解释 Ruby 中预定义的模块。 - **Chapter 24 Standard Library**...
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 ...
handling capabilities, and the use of assertions to validate the expected behavior of code. <br>Chapter 13Strings and Regular Expressionsdescribes the built-in language and runtime support for ...
2. **Built-in Functions and Exceptions**(内置函数与异常) - Python提供的各种内置函数,如len()、print()等。 - 异常处理机制及常见异常类型。 3. **Python Runtime Services**(Python运行时服务) - ...
- **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, ...
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 ...
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...
2 Getting In and Out of gdb . . . . . . . . . . . . . . . . . . . 11 2.1 Invoking gdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.1 Choosing ...
2.2.1 OK, I’m In. Now What? .............................................25 2.2.2 Just Publish Something! .............................................................25 2.2.3 Go Look At It! ...........
3. New Features and Enhancements in Spring Framework 4.0 ............................................ 17 3.1. Improved Getting Started Experience .........................................................
3. New Features and Enhancements in Spring Framework 4.0 ............................................ 17 3.1. Improved Getting Started Experience .........................................................