Earlier, we saw how a computer runs code line by line. We will now see how each line can also involve several underlying steps.
Run the code in this example to see a step-by-step execution of a simple statement.
Why is 15 + 17 calculated first, and console.log executed second? Let's dive a little deeper to understand.
Whenever we use console.log, we need to provide it with a value to write to the console, such as text or a number. However, 15 + 17 is not a value. But it is an expression that can be evaluated to a value.
When a computer is running code and sees an expression, it first evaluates that expression down to a single value. As we will see in the following lessons, a single line of code can often involve many such evaluation steps. Understanding how step-by-step evaluation works is critical to understanding code, CodeSteps.dev shows and explains these evaluations as it runs code.
Output (Console)