P3.3: JS Functions & Scope
Functions are blocks of reusable logic. Scope determines the accessibility of variables declared in the code.
1. Declaring Functions
Functions are created using declarations or modern ES6 arrow expressions:
// Classic Declaration
function add(a, b) {
return a + b;
}
// ES6 Arrow Function (Prevalent in React)
const multiply = (a, b) => a * b;

Marijn HaverbekeView Profile 🔗
Real-World Developer Case Study RoleAuthor of Eloquent JavaScript
Salary₹70 Lakhs/yr equivalent
CompanyCodeMirror
Core Tech Stack
JavaScript CompilersText EditorsCodeMirror
“Functions are the building blocks of abstraction. Understand how functions closure works—they remember the variables of the scope they were created in.”