
What Actually Happens When You Call A Function?
The React Show
00:00
How to Execute a Function in JavaScript
When the JavaScript engine sees the identifier add with parentheses behind it, it knows that we're invoking a function. So it searches through the environment and it finds its value. It then takes those two values and pushes a new frame onto the front of the environment mapping a and b to their respective values. And now that we've updated our environment with the new frame for the add function, we need to actually execute the body of the add function. This is very straightforward. Congratulations. We've defined and actually executed a function. Huh. Thomas. I really didn't know it was so simple," Sally says. "It always seemed like magic to me."
Transcript
Play full episode