- Home
- /
- Tutorials
- /
- JavaScript Tutorial
- /
- JavaScript Pure Functions
JavaScript Functions
JavaScript Pure Functions
A JavaScript pure function always returns the same result for the same input and changes nothing outside itself.
Anything a function changes outside itself is called a side effect.
A pure function has none, which makes it easy to trust and easy to test.
Example
Example
javascript
function add(a, b) {
return a + b;
}
console.log(add(2, 3));
console.log(add(2, 3));