Parts of a Function
function hello(firstname, lastname) {
alert("Hello " + firstname + " " + lastname+"!");
return "complete";
}
-
function: defines the function.
-
name: name of the funciton, hello in our case. Use this later
to call the function.
-
parameter list, parameters (arguments): data passed to the function.
firstname and lastname in our example. Contained in parenthesis.
-
{}: curly braces define the boundaries of the function. Tell
where it begins and ends.
-
statements: the guts of the function, between the curly braces.
-
return value (optional): a value that can be passed back to the
calling statement. Often used when the function performs a transformation
on the values passed to it.
Accessing the Function
Home
Internet II: Day 2