title: Best practice: Javascript/Jquery saving variable for later use
body: <p>I'm sure, this question has been answered somewhere before but I just couldn't find it.</p>
  
  <p>If within a function a variable has been defined, what is the best practice to save it for later use?  1. Saving it "globally"?<br />
  <code>foo = 'bar';<br />...<br />function bar(){<br />
         ...<br />
         foo = 'bat';<br />
         return foo;<br />
       }<br />...
  </code></p>
  
  <p>Here, the variable will be altered later on.
   2. Or saving it within a hidden form field within the HTML-DOM?</p>
  
  <p>`Thanxs!</p>