1096 Part IV . JavaScript Core Language Reference (Post office web site)
1096 Part IV . JavaScript Core Language Reference function outerB() { statements function innerA() { statements } function innerB() { statements } statements } A good time to apply a nested function is when a sequence of statements need to be invoked in multiple places within a large function but those statements have meaning only within the context of the larger function. In other words, rather than break out the repeated sequence as a separate global function, you keep it all within the scope of the larger function. You can access a nested function only from statements in its containing function (and in any order). Moreover, all variables defined in the outer function (including parameter variables) are accessible to the inner function; but variables defined in an inner function are not accessible to the outer function. See the section, Variable Scope: Globals and Locals later in this chapter for details on how variables are visible to various components of a script. Function parameters The function definition requires a set of parentheses after the functionName. If the function does not rely on any information arriving with it when invoked, the parentheses can be empty. But when some kind of data is arriving with a call to the function, you need to assign names to each parameter. Virtually any kind of value can be a parameter: strings, numbers, Booleans, and even complete object references such as a form or form element. Choose names for these variables that help you remember the content of those values; also, avoid reusing existing object names as variable names because it s easy to get confused when objects and variables with the same name appear in the same statements. You must avoid using JavaScript keywords (including the reserved words listed in Appendix B) and any global variable name defined elsewhere in your script. (See more about global variables in the following sections.) JavaScript is forgiving about matching the number of parameters in the function definition with the number of parameters passed along from the calling statement. If you define a function with three parameters and the calling statement specifies only two, the third parameter variable value in that function is assigned a null value. For example: function oneFunction(a, b, c) { statements } oneFunction( George , Gracie ) In the preceding example, the values of a and binside the function are George and Gracie , respectively; the value of cis null. functionObject
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.