Created
October 8, 2018 14:09
-
-
Save devarajchidambaram/169097cbc3eba20380bf5a35a1d8186b to your computer and use it in GitHub Desktop.
Pure vs Impure function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Characteristics of Pure Function: | |
The return value of the pure functions solely depends on its arguments Hence, if you call the pure functions with the same set of arguments, you will always get the same return values. | |
They do not have any side effects like network or database calls | |
They do not modify the arguments which are passed to them | |
Characterisitcs of Impure functions | |
The return value of the impure functions does not solely depend on its arguments Hence, if you call the impure functions with the same set of arguments, you might get the different return values For example, Math.random(), Date.now() | |
They may have any side effects like network or database calls | |
They may modify the arguments which are passed to them | |
**/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment