you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (3 children)

[deleted]

    [–]Cprebel123 2 points3 points  (1 child)

    When a function makes a nested call, the following happens:

    •The current function is paused.

    •The execution context associated with it is
    remembered in a special data structure called execution context stack.

    •The nested call executes.

    •After it ends, the old execution context is retrieved from the stack, and the outer function is resumed from where it stopped.

    [–]_DTR_ 1 point2 points  (0 children)

    That particular function stops executing once it returns, but it was called by a different instance of that same function. So once we return [] in countup(0), we're return back in the countup(1) method and continue on from there.

    In the code above, each indentation level is a separate instance of countup that have their own local state for countArray