Function Object
A Function object contains the definition of a function that you define in Siebel eScript. It returns the code that you configure this function to return. For more information, see Return Statement of a Function Object.
Format A
function funcName( [arg1 [, ..., argn]] )
{
body
}
In format A you declare a function, and then call it in your code. It is the standard way to define a function.
Format B
var funcName = new Function([arg1 [, ..., argn,]] body );
In format B you explicitly create a function. If you use format B to create a function object, then Siebel CRM evaluates it each time it uses this function. This configuration is not as efficient as format A because Siebel CRM compiles a declared function only one time instead of evaluating it every time it uses the function.
Arguments
The following table describes the arguments for a function object.
Argument | Description |
---|---|
funcName |
The name of the function. |
arg1 [, …, argn] |
An optional list of arguments that the function accepts. |
body |
The lines of code that the function runs. |
Example 1
The following example uses format A to declare a function named AddTwoNumbers. It uses AddTwoNumbers as the name of the function:
function AddTwoNumbers (a, b)
{
return (a + b);
}
The following example uses format B to create a function named AddTwoNumbers. It uses the Function constructor to create a variable named AddTwoNumbers. The value of this variable is a reference to the function that the Function constructor creates:
AddTwoNumbers = new Function ("a", "b", "return (a + b)");