0

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.

enter image description here

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

enter image description here

are those terms the same or it has a subtle difference? or is it my mistake to understand them? thanks

3
  • I'd not recommend learning internal mechanism like this as first step to learn JavaScript, they are abstract enough and you usually need not worry about them. Commented Jul 4, 2020 at 5:26
  • Agree with @appleapple . There is enough information overload involved in learning the basic code writing and figuring out how to make your app do what you need it to. You can easily find yourself going down a lot of time wasting rabbit holes just to come out more confused than when you started when you realize you don't know enough of the basics to absorb the advanced topics. There are going to be many many things you will come across that you need to just store in the "I know it exists" drawer and come back to them on an as needed basis
    – charlietfl
    Commented Jul 4, 2020 at 5:32
  • when using recursion remember about proper base case so then the stack won't overflow
    – grzesiekmq
    Commented Jul 4, 2020 at 8:04

1 Answer 1

0

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.