filmov
tv
Functional JavaScript Tutorial - #3 Side Effects & Pure Functions
![preview_player](https://i.ytimg.com/vi/r8fUwk5gLNM/maxresdefault.jpg)
Показать описание
A side effect is a change of system state or observable interaction with the outside world that occurs during the calculation of a result. A common side effect is to generate output beyond the return value. IO (input/output) operations such as file reading, database access or HTTP requests are another example of side effects.
Side Effects are the primary source of complexity in software. They are hidden inside the function's body and not captured by its signature. On top of that, side Effects may break compositional nature of functions.
Pure functions produce the same output for the same inputs *and* there are no side-effects. It's a computation that is only influenced by its input and that only influences its output.
Pure Functions are easier to reason about. They don't have side effects. This way, pure functions can only influence the behavior of a program through their output. As the output is deterministic (it can reliably be calculated using only the input values), pure functions will always preserve referential transparency. Additionally, using pure functions may increase program's performance.
Functional programming is a programming paradigm in which you build programs by
composing functions. The computation is then the evaluation of those functions.
Functional programming focuses on the usage of pure functions and on avoiding
shared, mutable state. This programming paradigm is declarative. Functional code
is usually more concise and easier to test.
In this mini series, we will embark on an exciting journey to learn a bit about
functional programming by using JavaScript. Presented concepts will be mostly
universal and applicable to other programming languages. This series is created with beginners and non-programmers in mind; don't worry, we will take it slowly!
#functional #javascript #tutorial
Side Effects are the primary source of complexity in software. They are hidden inside the function's body and not captured by its signature. On top of that, side Effects may break compositional nature of functions.
Pure functions produce the same output for the same inputs *and* there are no side-effects. It's a computation that is only influenced by its input and that only influences its output.
Pure Functions are easier to reason about. They don't have side effects. This way, pure functions can only influence the behavior of a program through their output. As the output is deterministic (it can reliably be calculated using only the input values), pure functions will always preserve referential transparency. Additionally, using pure functions may increase program's performance.
Functional programming is a programming paradigm in which you build programs by
composing functions. The computation is then the evaluation of those functions.
Functional programming focuses on the usage of pure functions and on avoiding
shared, mutable state. This programming paradigm is declarative. Functional code
is usually more concise and easier to test.
In this mini series, we will embark on an exciting journey to learn a bit about
functional programming by using JavaScript. Presented concepts will be mostly
universal and applicable to other programming languages. This series is created with beginners and non-programmers in mind; don't worry, we will take it slowly!
#functional #javascript #tutorial
Комментарии