| title | logoImg | theme | transition | highlightTheme | slideNumber | loop | enableMenu | enableChalkboard |
|---|---|---|---|---|---|---|---|---|
Functions |
night |
slide |
monokai |
true |
true |
false |
false |
This chapter should cover the following:
- Anatomy of functions
- Catagories of Functions
- Simple Example of Each function
- Links to subjections for detailed breakdown of each
A functions is block of reusable code to preform a task. {.fragment}
First you create a function, then the function must be called in order to execute. {.fragment}
First-class object... {.fragment}
- Explain how you can use hoisted functions?
- Explain why you use a return statement?
- Explain the difference between Parameters and Arguments
Simple Functions {.fragment }
Async Functions {.fragment }
:::block
Object Oriented Functions This gets it's own chapter
{.fragment } :::
:::block Simple Functions
- Function Declaration
- Function Expression
- Anonymous Functions
- Arrow Functions
- Curried Function
- Closure
- IFFE
:::
:::block Object Oriented Functions
- Constructor Function
- Class
- factory
- etc
- etc
:::
:::block Async Functions
- Callbacks VS H.O.F.
- Promises
- Generator
- Async / Await
- Async Generator
:::
What a function declaration looks like:
function add(param1, param2){
return param1 + param2;
};
add(1, 2) //return a value of 3Has the following Features:
Block Syntax, with {} at the begining and the end of the function and usually followed by a ; {.fragment .current-only data-code-focus=1-3}
:::block
- Function keyword
- Name of function,
add - Parameters
(param1, param2), which act as variables inside the functions definition. {.fragment .current-only data-code-focus=1-1} :::
Return keyword, ends the function and the result is returned {.fragment .current-only data-code-focus=2-2}
:::block
-
Calling the Function
-
When the function is called, we pass values into the arguements
(1,2){.fragment .current-only data-code-focus=4-4} -
When the function is called, we pass values into the arguements
(1,2){.fragment .current-only data-code-focus=1-2}
:::
- Its return value is the same for the same arguments (no variation with local static variables, non-local variables, mutable reference arguments or input streams from I/O devices).
This defines the doument type as html. {.fragment .current-only data-code-focus=1-1}
- Its evaluation has no side effects (no mutation of local static variables, non-local variables, mutable reference arguments or I/O streams).
Callbacks VS H.O.F.
Promises
Generator
Async Functions
Constructor Function
Class
This defines the doument type as html. {.fragment .current-only data-code-focus=1-1}