Search within TutorialsPark

Javascript Functions


Functions are a set of Javascript statements that perform a specific task.


Javascript Function: Return Values

The function recieves the arguments and then operates on them, the result of the function is returned using the return statement .

The moment the javascript interpreter encounters the return statement the value of the function, calculation etc is returned.No further processing takes place.

Syntax: Javascript Function Return Values

Example: Javascript Function Return Values

Give it a TRY! » Note: Incase a function doesn't have a return statement, it returns the undefined value


Javascript : Anonymous Functions as Variables

A Javascript function can also be assigned to a variable as a value, the variable is just like any other ordinary variable except that its value is a function definition.

The variable can be used a reference for the function, the javascript operator () is used to denote that the function is to be called.

Syntax: Javascript Anonymous Function as a Variable

Example: Javascript Anonymous Functions as a Variable

Give it a TRY! » Note: Incase a function doesn't have a return statement, it returns the undefined value