title: Take commas from input field, remove them, and store value with remove comma in different value
body: <p>I have an input box:</p>
  
  <pre><code>&lt;input id='first' placeholder="0" type="text" maxlength="10"autocomplete="off"/&gt;
  </code></pre>
  
  <p>which automatically adds commas when numbers are written:</p>
  
  <pre><code>$("#first").keyup(function(event) {
  
       // skip for arrow keys
       if(event.which &gt;= 37 &amp;&amp; event.which &lt;= 40) return;
  
       // format number
       $(this).val(function(index, value) {
            return value
            .replace(/\D/g, "")
            .replace(/\B(?=(\d{3})+(?!\d))/g, ",")
            ;
            });
  });
  </code></pre>
  
  <p>I want to store the input value (with commas) in a var and remove the commas with a jquery code, then use the new value of the input (one without commas) as a new variable.</p>
  
  <pre><code>var firstValue = Number($('#first').val());
  </code></pre>