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.
Loading...
Related Quiz
- Question 3: When setting up a mono-repo with multiple packages, how does ES6 module resolution impact the sharing of code across different packages?
- For side effects only, without importing any variables, use import _________ from 'module-name'.
- How does the inclusion of "type": "module" in the package.json affect module resolution in Node.js?
- What is a key difference between functional composition and method chaining?
- To inherit properties and methods from another class in ES6, use the ________ keyword.