Function - Pure Function

1 - About

Pure functions are called “pure” because they do not attempt to change their inputs, and always return the same result for the same inputs.

The result is then predictable.

3 - Example

Pure

function sum(a, b) {
  return a + b;
}

Not Pure

function withdraw(account, amount) {
  account.total -= amount;
}

4 - Documentation / Reference

code/function/pure.txt · Last modified: 2017/09/17 18:31 by gerardnico