Thunk, "past tense of think", can be used when a calculation may, or may not have to be performed at a later point in time, and its value is needed several times. This is an example of lazy evaluation, and can be used to avoid unnecessary calculations and to make state immutable.
function |
some function that returns the desired value |
return the value. If calculation is done, use previous value, otherwise do calculation.