A little about expressions
Following your edit, it seems you're asking about expressions
.
An expression
is basically a snippet that has a value
. In your example both Jump(3)
and var x = 3
are expressions, as both have a value. In other words, Jump(3)
is an expression with the value 6
and (x=3)
is actually an expression which evaluates to 3
.
The only difference between the two is that the first expression also assigns a value with the assignment operator
(i.e. =
), while the second expression is "just" a value. For that matter, in your example, the variable x
is also an expression that evaluates to 3
.
For more on this subject see MDN - Expressions and operators in Javascript
More to the point
This means that when you pass an argument to a function by-value, you're essentially passing the value of the expression. So in your example, Jump(x)
, Jump(3)
, Jump((x=3))
and Jump(Jump(1.5))
would all evaluate to 6
.
Naturally, it's much less costly to store the value of common operations in a variable that would be quickly evaluated as an expression, than to have the calculation done each time the expression is evaluated.