Impure function VS side Effect

Pure functions are predictable and they will always return a value.
Impure functions are not predictable, they may or may not return a value, and even if they return a value it may be different even if same paramtered are passed
Pure functions do not have side effects. Impure functions can cause side effects. Pure functions return the same output if we use the same input parameters. However, impure functions give different outcomes when we pass the same arguments multiple times.
Pure functions are functions that always return the same value for same inputs, for example:
function add(a,b) {
return a + b
}
console.log(add(4,5));
on the other hand an impure function might be something which won't always return the same value for same input example :
Math.random() it will always return a different value
A side effect is any function performs which is not related to predicting final output , like making a http request, changing something on the dom...




