Hello everyone 👋, I hope you are doing great.
The V8 engine has two main components
- Heap is an unstructured memory that is used for memory allocation of the variables and the objects.
- Call Stack is a LIFO data structure that is used for function calls that record where we are in the program.
If you call a function, it's pushed on the top of the Call Stack, and when the function returns, it's popped from the top of the Call Stack.
Let's take an example.
Let's take another example that contains an error.
When the V8 engine encounters an error, it prints a stack trace. A stack trace is basically the state of the Call Stack.
Let's take another example that blows up the Call Stack 💥.
We can do this by using a recursive function.
A recursive function calls itself again and again. At some point in time, the number of function calls exceeds the actual size of the stack, and the browser detects this to take action by throwing an error.
In the next article, we will learn about Web APIs, Callback Queue, and Event Loop.
Thanks for reading! My name is Bipin Rajbhar; I love helping people to learn new skills 😊. You can follow me on Twitter if you’d like to be notified about new articles and resources.