Functions are just sub-program

Functions can be pictured as sub program, this allow us to bisect a large program into manageable pieces.

Bindings and scopes

Every binding defined withing a function (every variable declaration) is scoped to that function and exists only within that function. This provides isolation between functions.

  • For every function you create, you basically are defining a separate world, disconnected from your code. withing that same function, you can create other worlds, thus nested stops.

The call stack

For every function definition, we create a new world, when running that world or calling it(executing our function), the program is disconnected from the outer world(the main context)

  • After the function has finished it’s execution, the program must continue it’s normal flow in the main context / world)
  • That’s why the call stack is there to keep track of what function is being runed and once it’s done executing, it makes sure remove it so that our program can continue it’s normal flow