Chapter 3 DynaScript Predefined Objects
Enables the creation of functions.
Standard: ECMAScript
To use a Function property:
Function.propertyName
To use a Function method:
Function.MethodName( parameter )
The function constructor can be used to create a function on the fly:
funcName = new Function( [[parameter1 [, parameter2...]], body] );
The function keyword can also be used to create a function, in which case the function is not created until it has been called from somewhere else in the script:
function funcName ( [parameter1 [, parameter2...]], ) {
body
}
This example creates two Function objects called square and square1 and executes them:
<!--SCRIPT
// function created with a constructor
square = new Function( "number", "return number * number;" );
// function created with the keyword
function square1 ( number) {
return number * number
}
document.writeln( square(5) );
document.writeln( square1(5) );
-->
Copyright © 1999 Sybase, Inc. All rights reserved. |