Back to Lessons
Functions and Scopes
Master function declarations, arrow functions, and variable scope
Overview
Functions are reusable blocks of code that perform specific tasks.
Function Declaration: function greet(name) { return "Hello, " + name; }
Arrow Function (modern syntax): const greet = (name) => "Hello, " + name;
Scope determines where variables are accessible. JavaScript has three types of scope: - Global Scope: Variables accessible everywhere - Function Scope: Variables accessible only within the function - Block Scope: Variables accessible only within the block (let, const)
Code Example
Loading...