javascript what is a pure function? code example
Example: what is a pure function
Referential transparency:
always gives the same return value for the same arguments.
the function cannot depend on any mutable state.
Side-effect free:
cannot cause any side effects.
includin I/O (e.g., writing to the console or a log file),
modifying a mutable object,
reassigning a variable
writing to the console
NOT pure functions:
console.log
element.addEventListener
Math.random
Date.now
$.ajax
const o4 = Object.freeze({ foo: 'cant change me' });