JavaScript Fundamentals
Learn variables, types, functions, objects, arrays, scope and closures well enough that React and Node.js feel natural.
Beginner · about 16 hours · difficulty 2/5
JavaScript is the foundation of everything else in this track. Weak JavaScript shows up later as confusing React bugs, so invest here.
Language core
- let and const (avoid var), primitive types, and the difference between == and === (always use ===).
- Functions: declarations, arrow functions, default and rest parameters.
- Objects and arrays: destructuring, spread, optional chaining (?.) and nullish coalescing (??).
- Array methods: map, filter, reduce, find, some, every, sort. You will use map and filter in nearly every React component.
Scope and closures
Variables live in block, function or module scope. A closure is a function that remembers variables from where it was created. React hooks, event handlers and middleware all depend on closures.
Reference vs value
Objects and arrays are passed by reference. Mutating an array in place is the root of many "my React state did not update" bugs. Prefer creating new arrays and objects with spread or map.
Modules
ES modules (import and export) split code into files. Both the browser and modern Node.js support them.
Pitfalls
- Mutating shared objects by accident.
- Confusing this inside regular functions vs arrow functions.
- Learning a framework before you can write a plain function that groups and sums data.
You are ready to move on when you can take an array of placement offers and, without looking anything up, compute the average CTC per branch using map, filter and reduce.
Key concepts
- Variables and types
- Functions and arrow functions
- Objects, arrays and destructuring
- Array methods: map, filter, reduce
- Scope and closures
- Reference vs value
- ES modules
- Classes and prototypes
- Error handling with try/catch
Mini project
Write a Node.js script that reads a JSON file of placement offers (company, branch, CTC in lakhs) and prints per-branch averages, the top five offers and the number of companies, using only array methods.
Check yourself
Explain what a closure is and give an example from event handlers or a counter function.
Free resources
- The Modern JavaScript Tutorial (javascript.info)
- JavaScript Guide (MDN)
- freeCodeCamp JavaScript Algorithms and Data Structures (freeCodeCamp)