/
๐Ÿ“

Side effects

https://en.wikipedia.org/wiki/Side_effect_(computer_science)
programming
On this page
  • Title

Title

According to Wikipedia, a function or expression is said to have a side effect if it modifies some state outside its local environment.

In this figure, we have a variable x that is outside the scope of two functions. Clearly, after the Function_2 call, the value of x changes which means that Function_2, other than returning value(if any), is interacting with variables outside its local environment and thus has a side effect.

In general, any lasting effect that occurs in a function, not through its return value, is called a side effect.

Edit this page
logo
Code-related notes and snippets