title: jQuery Array Undefined Error
body: <p>I have been wrecking my brains trying to figure out why I get an undefined error for the array statusIdValues when I hit the first push in the code below. Its initialised in a ready function and is pushed into when a checkbox state changes.</p>
  
  <pre><code>$(document).ready(function () {
    var statusIdValues = [];
  
        $(':checkbox').change(function () {
  
        if ($(this).is(":checked")) {
            statusIdValues.push($(this).attr("value"));
        }
        else {
             var index= statusIdValues.indexOf($(this).attr("value"));
             if (index &gt; -1) {
             statusIdValues.splice(index, 1);
        }
      });
   });
  </code></pre>
  
  <p>Any help would be appreciated.</p>