Recognise pure functions

In notebook:
FrontEndMasters Hardcore Functional
Created at:
Functional Programming JavaScript Fundamentals
Functions that don't change anything are called "pure". 

Their purity makes them
  • testable
  • portable
  • memoizable (remembering the results of a function with a given input and just giving back the same result next time it's called with the same values)
  • parallelizable
Shows a quiz

Shows a random number generator function (pure function)!!
  function random(m_w, m_z) {
  m_z = 36969 * (m_z & 65535) + (m_z >> 16)
  m_w = 18000 * (m_w & 65535) + (m_w >> 16)
  return (m_z << 16) + m_w
This spreads pretty evenly numbers. 

Shows another example that receives ​console​ as an argument and logs something out. This is impure because it changes something in the outside. 

It's impure because ​console​ is an impure function. (not parallelisable)