Methods and FunctionsMethods are behaviors applied on objects. Different objects have different methods available. Additional methods may be created, by writing appropriate JavaScript functions. Besides their traditional use, functions in JavaScript can be used not just as object methods, but also as constructors and event handlers. Method and function invocation
Defining a function in JavaScript This is similar as in most other programming languages, namely:
where parameter-list is the list of parameters, separated by commas. The values are assigned to the function local variables named (within parentheses), passed by name. Data type and number of of arguments are not checked in JavaScript. A return statement is also optional. Sample function that loads the appropriate browser-specific HTML JavaScript Seminar Home | Previous | Next Last Modified: March 2, 2001 UIC Instructional Technology Lab |