|
Functions are one of the core building blocks of JavaScript. |
|
|
Here’s a function that takes two |
|
|
JavaScript requires explicit returns.
By default, a function will return |
|
|
Call a function with |
|
|
Because JavaScript does not define types, we can use the same function for multiple types. |
|
|
Function definitions may specify a default value. This is also known as an optional parameter |
|
|
Optional parameters do not need to be specified but will be overridden when present |
|
|
|
|
Function definitions are hoisted within the file. We can call a function before its definition. |
|
|
|
|
Functions can be assigned as values, they can also be defined without a name. This makes them first class citizens. |
|
|
Arrow Functions can be created using the |
|
|
The |
|
|
Rest parameters are the remaining arguments combined into an array |
|
|
Next example: Closures.