Answers for "what is a pure function"

0

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' }); //The object is immutable and the variable cannot be reassigned. This is what we want!!!!!!!!
Posted by: Guest on November-19-2020

Code answers related to "what is a pure function"

Code answers related to "Javascript"

Browse Popular Code Answers by Language