title: Using $(this) inside a setInterval in jQuery
body: <p>I am using this code inside a jQuery plugin:</p>
  
  <pre><code>setInterval(function() {                        
     localStorage.setItem("flag", "set");
     var data = $(this).serializeArray();
     console.log($(this));
     $.each(data, function(i, obj) {
        localStorage.setItem(obj.name, obj.value);
     });
     console.log('saved');
     console.log(localStorage);                       
  }, 5000);
  
  if (localStorage.getItem("flag") == "set") {
     alert("This form has saved data!");
     var data = $(this).serializeArray();
     console.log($(this));
     $.each(data, function(i, obj) {
        $("[name='" + obj.name +"']").val(localStorage.getItem(obj.name));
     });                      
  }
  </code></pre>
  
  <p>Now strangely, the first <code>$(this)</code> contains the form (which the plugin is ran on), but the second <code>$(this)</code> contains <code>DOMWindow</code>. How come the two <code>$(this)</code> contain different things? Is it because the first is inside a <code>setInterval</code>?</p>