Function Programs
declarations, arrows, callbacks, closures. Closures are just a function that kept its bag.
3 programs · open one, then the next
Start with Basic Functions- 01Basic FunctionsBeginnerfunction foo() {} vs const foo = () => {}. Hoisting is the difference you feel.Open example →js// Method 1: Function Declaration function greet(name) { return "Hello, " + name + "!"; }
- 02Callback FunctionsIntermediatePass a function into a function. setTimeout is the example everyone copies.Open example →js// Callback: Function passed as argument to another function // Example 1: Simple callback function greet(name, callback) {
- 03ClosuresIntermediateInner function keeps the outer variables. That counter example is the whole point.Open example →js// Closure: Function has access to outer function's variables // Example 1: Basic closure function outerFunction(x) {