1function myFunction(parameter1, parameter2,..., parameterN) {
2
3 // function body
4
5}
6
7/*A function defined in this way is a named function
8(myFunction, in the example above).
9
10Many programming languages, including JavaScript, allow us to create
11anonymous functions, which do not have names. We can create an anonymous
12function by simply leaving off the function name when defining it:*/
13
14function (parameter1, parameter2,..., parameterN) {
15
16 // function body
17
18}
1/*Anonymous functions are often assigned to variables when they are
2created, which allows them to be called using the variable's name.
3
4Let's create and use a simple anonymous function that returns the sum
5of two numbers*/
6
7let add = function(a, b) {
8 return a + b;
9};
10
11console.log(add(1, 1));
12
13//2
14
15/*The variable add refers to the anonymous function created on lines
161 through 3. We call the function using the variable name, since the
17function doesn't have a name.*/