Chapter VI · Functions
Arrow Functions
Arrow functions provide a concise syntax for writing functions with lexical this bindings.
01 How It Works
Think of a streamlined mathematical arrow equation shorthand.
Arrow functions omit the function keyword and implicitly return single-line expression values.
example.js
const multiply = (a, b) => a * b;
console.log(multiply(4, 5)); // 20
1. Specify parameters in parentheses.
2. Add the arrow token (=>).
3. Provide expression logic or block code.
02 Practical Example
Here is how you might see this concept applied in real-world code:
practical.js
const square = x => x * x;
console.log(square(6)); // 36
Key Takeaway
Arrow functions offer compact syntax and lexical context preservation.