JavaScript Tutorials - Herong's Tutorial Examples - 2.33, by Herong Yang
Defining Your Own Functions
This section provides a quick description of how to define your own functions and some basic features of a JavaScript function.
Like many programming languages, JavaScript allows you to define your own functions. JavaScript uses the following syntax format to define a new function:
function function_name(parameter_1, parameter_2, ...) { statement_1; statement_2; ... return return_expression }
There are 4 areas you need to know in order to define a new function:
A JavaScript function has the following basic features:
A tutorial example will be given in the next section showing your how to define a new function.
Table of Contents
ECMAScript Language Specification and JavaScript Dialects
Data Types, Variables and Expressions
Creating, Accessing, and Manipulating Arrays
►Defining and Calling Functions
Defining Your Own Functions - Example
Calling Your Own Functions - Example
Passing Parameters by Value or by Reference
Function Parameters Are Passed as Local Copies
Function Parameters Are Passed as Local Copies - Example
Global and Local Variables - Scope Rules
Collision of Global and Local Variables - Examples
"return" Statement and Return Value
Web Browser Supporting JavaScript
Server-Side and Client-Side Web Scripting
Defining Your Own Object Types
Inheritance of Properties and Methods through the Prototype Object Chain
'jrunscript' - JavaScript Shell Command from JDK
Using Functions as "Function" Objects
Introduction to Built-in Object Types
W3C's Document Object Model (DOM) Specifications