title: jQuery - Updating a property of a $.data() object
body: <p>Let's say I stored a object/function as data in an element using jQuery</p>
  
  <pre><code>function Person() {
      this.age = 17;
      this.gender = 'female';
  }
  
  $.data( $('.some-random-element'), 'personDetails', new Person());
  </code></pre>
  
  <p>Let's say that I want to change the age to 18 for that given element. How would go about doing that? </p>
  
  <p>Do I do it like...</p>
  
  <pre><code>$('.some-random-element').data('personDetails').age = 18;
  </code></pre>
  
  <p>Or...</p>
  
  <pre><code>$('.some-random-element').data('personDetails', $.extend( $('.some-random-element').data('personDetails'), { age : 18 } ));
  </code></pre>
  
  <p>...or is the best and most efficient solution none of the above?</p>
  
  <p>I am confused because I am not sure if <code>$('.some-random-element').data('personDetails')</code> returns by reference or value.</p>