• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

4. Variables, Functions, and Flow Control > 4.3. Nesting Named Functions

Nesting Named Functions

NN 4, IE 4

Problem

You want to create a function that belongs to only one other function.

Solution

Starting with IE 4 and NN 4, you can nest a function inside another function according to the following syntax model:

function myFuncA( ) {
    // statements go here
    function.myFuncB( ) {
        // more statements go here
    }
}

In this construction, the nested function may be accessed only by statements in the outer function (but see the Discussion about Netscape 6 and later). Statements in the nested function have access to variables declared in the outer function, as well as to global variables. Statements in the outer function, however, do not have access to the inner function’s variables.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint