Java Reference
In-Depth Information
In this chapter we have learned the following:
• Functions are first-class objects that behave the same way as all other values.
• Function literals can be defined using the function declaration, or by creating a
function expression by assigning an anonymous function to a variable.
• All functions return a value. If this is not explicitly stated, the function will return
• A parameter is a value that is written in the parentheses of a function declaration
and can be used like a variable inside the function's body.
• An argument is a value that is provided to a function when it is invoked.
• The arguments variable is an array-like object that allows access to each argu-
ment provided to the function using index notation.
• Default arguments can be supplied to a function by checking if the actual argument
entered has a value of undefined.
• Variables defined using var inside functions have local scope . This means that they
are only available inside the function they are defined in.
• Variables defined without var have global scope , which means they can be ac-
cessed (and overwritten) from anywhere in the program.
• Variable declarations are hoisted to the top of a functions scope, but variable assign-
ments are not.
• Function declarations can be invoked before they are defined because they are hois-
ted to the top of the scope, but function expressions cannot be invoked until after
they are defined.
• A callback is a function that is provided as an argument to another function.
Search WWH ::

Custom Search