Generally speaking, a function is a "subprogram" that can be called by code external (or internal in the case of recursion) to the function. Like the program itself, a function is composed of a sequence of statements called the function body. Values can be passed to a function, and the function can return a value.
1. function name
The same as a variable name
2. -> arrow symbol
Divided into thin arrow (->) and bold arrow (=>)
3. arguments
Arguments will be brought into the function
4. return value
The last line of function always be returned
- Outside Scope vs Inside scope
- Function will create a new scope
There are several ways to make new scope:
- Function
- Loop
- if...then...else