I'm now learning the basics of javascript. I face confusion about the difference between Stack and Call stack on the video and article I watch and read.
here is the stack I watch from the videos, and it said stack is a place to put your primitive values and pointer.
and in another article, I also got the term call stack, which is a data structure that stores information about the active subroutines of a computer program
are those terms the same or it has a subtle difference? or is it my mistake to understand them? thanks
Stack in Stack & Heap
sense is where a program stores a method's variables values or references (reference values are stored in Heap). For clarification I will call it State
of method.
But an application running, typically has only one active Stack
. so when you call another method (or itself recursively like your example) we need to save current State
and create new space to store State
of newly called method so we can restore previous method's State
afterward. We do this with a data structure called Stack
that support Last-In-First-Out (LIFO) to track called methods State
. We call that Call Stack
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.