Posts

Showing posts from August, 2026

Day 27: Performance & Memory

Image
 Day 27: Performance & Memory 1. Learning Objectives By the end of this lesson, you will be able to: Understand how JavaScript manages memory (stack vs heap, garbage collection) Identify and fix common memory leaks in web applications Optimize DOM manipulations to minimize reflows and repaints Use performance measurement tools ( performance.now() , console.time , Chrome DevTools) Apply debouncing and throttling to limit expensive operations Implement code splitting and lazy loading for faster initial page loads Use Web Workers to offload heavy computations from the main thread Write memory-efficient code by choosing appropriate data structures 2. Theory Memory Management in JavaScript JavaScript uses automatic memory management via garbage collection . The two main memory areas are: Area Stores Speed Size Stack Primitive values, function call frames, variable references Fast Small (limited) Heap Objects, arrays, functions, closures Slower Large (limited by...

Day 26: Event Loop & Concurrency

Image
 Day 26: Event Loop & Concurrency 1. Learning Objectives By the end of this lesson, you will be able to: Explain JavaScript's single-threaded, non-blocking execution model Describe the components of the event loop: call stack, heap, callback queue, microtask queue Distinguish between macrotasks (setTimeout, setInterval, I/O) and microtasks (Promise callbacks, queueMicrotask, MutationObserver) Predict the execution order of mixed synchronous, microtask, and macrotask code Understand how async/await and Promises interact with the event loop Recognize and avoid common pitfalls like blocking the event loop and starving the microtask queue Use requestAnimationFrame for smooth visual updates Apply concurrency patterns like cooperative yielding and task splitting 2. Theory JavaScript is Single-Threaded JavaScript has a single thread with one call stack. It can do only one thing at a time. However, the browser (or Node.js) provides Web APIs (like setTimeout , fetch ...

Day 25: Generators & Iterators

Image
 Day 25: Generators & Iterators 1. Learning Objectives By the end of this lesson, you will be able to: Understand what iterators and iterables are in JavaScript Create custom iterables by implementing the Symbol.iterator method Define generator functions using function* syntax Use yield to produce values lazily from generators Consume generators with for...of , spread operator, and destructuring Delegate generators using yield* Pass values back into generators using next(value) Recognize practical use cases for generators (infinite sequences, async flows, data processing) 2. Theory What are Iterators and Iterables? An iterable is an object that defines a sequence of values that can be iterated over. JavaScript has many built-in iterables: arrays, strings, Maps, Sets, etc. An iterator is an object that implements the iterator protocol — it has a next() method that returns an object with two properties: value — the next value in the sequence done — ...
EARN AT THE COMFORT OF YOUR HOME

Sponsored content