Skip to content

Conversation

swkarimi
Copy link

Pure function has two conditions:

  • Same output for same inputs.
  • No side effects.

For example, although the following function has the same output for the same inputs, it is not a pure function

function sum(a, b) {
    console.log(a + b);  // This is a side effect
    return a + b;
}

@Arman1263
Copy link

Arman1263 commented Oct 23, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants