Special Variables & Syntax
JS Calc includes special syntax to enhance your workflow.
Last Answer (@
or _ans
)
The special variable @
(internally _ans
for Math.js compatibility) holds the result of the last calculation that produced a displayable numerical, matrix, or unit value.
- Assignments (e.g.,
x=5
) and function definitions (e.g.,f(x)=x^2
) do not update@
. - Example:
> 2+3
5
> @ * 4
20
> x=10 // notice no output when assigning
> @ / 2
10
// because we only assigned 10 to x which
// did not change the @ from the previous solution
Implicit Last Answer
If an expression starts directly with one of the operators +
, -
, *
, /
, ^
, %
, JS Calc will automatically prepend the last answer (@
) to the expression.
- Example:
> 100 / 4
25
> + 75 // Evaluates as @ + 75 => 25 + 75
100
- Note for leading minus (
-
): If@
has a value, typing- 5
will be interpreted as@ - 5
. To enter a negative number directly when@
has a value, use parentheses(-5)
or ensure the input field is clear.