What is a pure function in JavaScript?

  • A function that has no side effects
  • A function that modifies global variables
  • A function that always returns the same output for the same input
  • A function that has asynchronous operations
A pure function is a function that always produces the same output for the same input and has no side effects. It does not modify external state, and it does not rely on external state. This property makes pure functions predictable and easy to test.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *