Advertisement Remove all ads
Advertisement Remove all ads
Advertisement Remove all ads
Distinguish Between
Differentiate pure and impure functions.
Advertisement Remove all ads
Solution
Pure Function:
- The return value of the pure functions solely depends on its arguments passed.
- 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.
- They do not modify the arguments which are passed to them.
Impure Function:
- The return value of the impure functions does not solely depend on its arguments passed.
- If you call the impure functions with the same set of arguments, you might get different return values. For example, random( ), Date( ).
- They have side effects.
- They may modify the arguments which are passed to them.
Concept: Pure Functions
Is there an error in this question or solution?