Functional programming is constantly on the rise, and with functional programming comes pure functions. Pure functions are the base of what functional programming is built upon, but they are useful even outside of functional programming. The idea of a pure function is a function that when given the same inputs always returns the same output. This function also must have absolutely no side effects and rely on no other state besides the input variables. It essentially works exactly the same as a math function. 2 + 2 always equals 4 no matter how many times you execute the function. 2 + 2 also never effects anything else outside it. For example 2 + 2 never causes 3 to change to 7 or some other side effect.

In this video I will be covering pure functions in depth by example. We will take an impure function and incrementally modify it so it is a pure function by the end of the video. I will also discuss the advantages and disadvantages of pure functions.


Materials/References:

Pure Functions Article: https://blog.webdevsimplified.com/2020-09/pure-functions
ES6 Rest/Spread Operator Video: https://youtu.be/NIq3qLaHCIs


🧠 Concepts Covered:

- What a pure function is
- How to avoid side effects
- Why pure functions are important
- The limitations of pure functions
- Immutability in pure functions


Find Me Here:

My Website: https://webdevsimplified.com
Patreon: https://www.patreon.com/WebDevSimplified
Twitter: https://twitter.com/DevSimplified
Discord: https://discord.gg/7StTjnR
GitHub: https://github.com/WebDevSimplified
CodePen: https://codepen.io/WebDevSimplified


#PureFunction #WDS #FunctionalProgramming