24.81. Function: a JavaScript functionECMAScript v1: Object Function24.81.1. Synopsisfunction functionname(argument_name_list) // Function definition statement { body} function (argument_name_list) {body} // Unnamed function literal functionname(argument_value_list) // Function invocation 24.81.2. Constructornew Function(argument_names..., body) 24.81.2.1. Arguments
24.81.2.2. ReturnsA newly created Function object. Invoking the function executes the JavaScript code specified by body. 24.81.2.3. Throws
24.81.3. Properties
24.81.4. Methods
24.81.5. DescriptionA function is a fundamental datatype in JavaScript. Chapter 8 explains how to define and use functions, and Chapter 9 covers the related topics of methods, constructors, and the prototype property of functions. See those chapters for complete details. Note that although function objects may be created with the Function( ) constructor described here, this is not efficient, and the preferred way to define functions, in most cases, is with a function definition statement or a function literal. In JavaScript 1.1 and later, the body of a function is automatically given a local variable, named arguments, that refers to an Arguments object. This object is an array of the values passed as arguments to the function. Don't confuse this with the deprecated arguments[] property listed earlier. See the Arguments reference page for details. 24.81.6. See AlsoArguments; Chapter 8, Chapter 9 |