title: Store the window.innerWidth value and calculate the difference with the new value on resize?
body: <p>How do I store the <code>window.innerWidth</code> value and calculate the difference with the new value on resize?</p>
  
  <pre><code>var w;
  
  function example {
  
  var onResize = function () {
  
      w = {width: window.innerWidth || document.body.clientWidth };
  
  if (difference of old width and this (new) width is 100) {
  // then do some stuff
  }
  
  window.addEventListener('resize', onResize);
  onResize();
  }
  </code></pre>
  
  <p>The solution would be to store the variable inside a global or outside on <code>onResize</code>, calculate the difference between the old and new data, do a condition of some sort: <code>(old width - new width) = 100?</code> and if the difference is 100 then do some stuff. </p>
  
  <p>Now conceptually I know how to achieve this, but how can I actually go about implementing it in JavaScript?</p>