Referentially Opaque Expressions
An expression is referentially transparent when it cannot be replaced with its return value.
Example:
1 |
|
At the time of writing the execution of today()
returned '2021-09-22T12:45:25.657Z'
. This result will change over time, so we cannot replace const isoDate = today()
with const isoDate = '2021-09-22T12:45:25.657Z'
which makes this expression referentially opaque.