Microsoft® JScript Function Object |
Language Reference Version 2 |
Creates a new function.
function functionname( [argname1 [, ... argnameN]] )
{
body
}
var functionname = new Function( [argname1, [... argnameN,]] body );The Function object syntax has these parts:
Part Description functionname The name of the newly created function argname1...argnameN An optional list of arguments that the function accepts. body A string that contains the block of JScript code to be executed when the function is called.
Syntax 1 is the standard way to create new functions in JScript. Syntax 2 is an alternative form used to create function objects explicitly.The function is a basic data type in JScript. Syntax 1 creates a function value that JScript converts into a Function object when necessary. JScript converts Function objects created by Syntax 2 into function values at the time the function is called.
For example, if you want to create a function that adds the two arguments passed to it, you can do it in either of two ways:
Example 1
function add(x, y) { return x + y; }Example 2
In either case, you call the function with a line of code similar to the following:var add = new Function("x", "y", "return x+y");add(2, 3);
© 1997 by Microsoft Corporation. All rights reserved.
file: /Techref/language/jscript/js576.htm, 3KB, , updated: 1997/9/30 02:44, local time: 2024/12/27 21:46,
3.148.104.103:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://massmind.ecomorder.com/Techref/language/jscript/js576.htm"> Function Object</A> |
Did you find what you needed? |
Welcome to ecomorder.com! |
Welcome to massmind.ecomorder.com! |
.