Why does my variable need a 'var' declaration, when it's already inside a var declaration?
<p>If a mod can help me phrase my question better, I'd appreciate it because it's hard to ask this without simply providing an example. Here is a function that I've created:</p>

<pre><code>$("#myField").on('keyup', function(event){
    var input = $(this), 
         val  = input.val(),
         inputGroup = input.parents('div.input-group')
         searchingIcon = $(inputGroup).find('i.auto-spinner'),
         button = $(inputGroup).find('span.input-group-btn &gt; button.btn'),
         key = event.which,
         typingTimer; // This throws an error typingTimer is not defined

    //Clear typing timeout on keypress
    clearTimeout(typingTimer);
    //.... more code below.. not important
  });
</code></pre>

<p>As you can see, I like to declare my vars in one simple var declaration followed by commas, however, in this case when I get to typingTimer, I get a undefined var error, as though it's looking for the variable, instead of defining an empty variable. If I simply change things to this:</p>

<pre><code>$("#myField").on('keyup', function(event){
    var input = $(this), 
         val  = input.val(),
         inputGroup = input.parents('div.input-group')
         searchingIcon = $(inputGroup).find('i.auto-spinner'),
         button = $(inputGroup).find('span.input-group-btn &gt; button.btn'),
         key = event.which;
   var typingTimer; // All is well again...

    //Clear typing timeout on keypress
    clearTimeout(typingTimer);
    //.... more code below.. not important
  });
</code></pre>

<p>Everything will work fine. This isn't the first time I've come across this phenomenon, and I don't really know the cause for it. Are there some limitations on how I can define variables not separated by (;)?</p>