Creates a new function.
The Function constructor allows a script to create functions at run time. The parameters passed to the Function constructor (all but the last parameter) are used as the parameters of the new function. The last parameter passed to the constructor is interpreted as the code for the body of the function.
JScript compiles the object created by the Function constructor at the time the constructor is called. Although this allows your script to have great flexibility in redefining functions at run time, it is also makes the code much slower. Use the Function constructor as little as possible to avoid slow scripts.
When calling a function to evaluate, always include the parentheses and required arguments. Calling a function without parentheses returns the Function object for that function. The text of a function can be obtained by using the toString method of the Function object.
Only JScript provides the Function object. Since it is not derived from a .NET Framework type, other Common Language Specification (CLS) languages cannot use it. Consequently, when type-annotating the parameters and return types of CLS-compliant methods, make sure to use the System.EventHandler data type instead of the Function object. However, you may use the Function object to type annotate identifiers other than parameters or return types. For more information, see Writing CLS-Compliant Code.