JavaScript Functions

ITWeb/개발일반 2008. 2. 20. 16:22

 
JavaScript Functions
-Functions are first-class objects
-Functions can be passed, returned, and stored just like any other value
-Functions inherit from Object and can store name/value pairs.
-A function is a reusable code-block that will be executed by an event, or when the function is called.
§function functionname(var1,var2,...,varX) {
§ some code
§ or
§ some code
§ return RETURNVALUE;
§}
-function foo() {} expands to var foo = function foo() {}

Inner Functions
-Functions do not all have to be defined at the top level (or left edge).
-Functions can be defined inside of other functions.
-Scope
§    An inner function has access to the variables and parameters of functions that it is contained within.
§    This is known as Static Scoping or Lexical Scoping.
: