InterviewHubPRO
Section Overview
Q400

Question 400 of 521

Part 6: Async Internals, Memory, Microtasks & Web APIs (329 - 403)

77%
JavaScript Internals (521 Qs)•Part 6: Async Internals, Memory, Microtasks & Web APIs (329 - 403)

What is heap

Heap(Or memory heap) is the memory location where objects are stored when we define variables. i.e, This is the place where all the memory allocations and de-allocation take place. Both heap and call-stack are two containers of JS runtime. Whenever runtime comes across variables and function declarations in the code it stores them in the Heap.

Screenshot

Practical Code Example

javascript
// Memory Heap: Unstructured memory region where objects, arrays, and functions are allocated:
const user = { name: 'Manthan' }; // Allocated on the Heap
const numbers = [1, 2, 3, 4, 5];  // Allocated on the Heap