Pure Functions
Learn about pure functions, their side causes, and their side effects.
What’s a pure function?
A pure function is one free from side effects and side causes. Side effects and side causes are either caused by or cause undesirable state changes in scopes both local and foreign to a function definition.
Side causes and side effects
A side cause is a product of impure input. It’s typically an input, such as a global variable used in a function body or an ORM (object-relational mapper) object specified as a function parameter. A side effect i is the result of impure functions. Side causes often cause side effects.
Problem 1
Look closely at the following code snippet:
Get hands-on with 1200+ tech skills courses.