-
Book Overview & Buying
-
Table Of Contents
The JavaScript Workshop
By :
Functions are the basic building blocks when it comes to writing JavaScript programs. A function is one or more statements that can optionally receive data input and provide data output. The statements in a function are not used until the function is invoked. Invoking a function is also known as calling the function.
JavaScript offers a few ways to define a function. We are going to look at function declarations, function expressions, and arrow function expressions as ways to define a function.
You can define a function as a statement. This is called a function definition or declaration. The syntax is as follows:
function name(optional parameter list) {
//Statements
//Optional return statement
}
It starts a line of code with the function keyword. It is followed by a name. The name is how the function will appear in other code. The list of comma-separated...