Is it possible to reference object within the same object?
<p>I've been messing around with jQuery plugin code and I'm trying to put all of my common variables into a single object for easy access. I have included a few examples below on how I've done this, but I'm wondering how others deal with this problem.</p>

<p>Lets say I have this</p>

<pre><code>var x = function(options){
 var defaults = {
  ulist   : $('ul#list'),
  listLen : $('ul#list').children().length
 }
 $.extend(options, defaults);
 // do other stuff
}
</code></pre>

<p>What I'm trying to do is use the <code>ulist</code> object in as a base, then find the number of <code>li</code>'s</p>

<p>I guess I could do this:</p>

<pre><code>var x = function(options){
 var defaults = {
  ulist   : $('ul#list'),
  listLen : 0
 }
 defaults.listLen = defaults.ulist.children().length;
 $.extend(options, defaults);
 // do other stuff
}
</code></pre>

<p>or this:</p>

<pre><code>var x = function(options){
 var defaults = {
  ulist : $('ul#list')
 };
 var defaults2 = {
  listLen : defaults.ulist.children().length
 }
 $.extend(defaults, defaults2);
 $.extend(options, defaults);
 // do other stuff
}
</code></pre>

<p>The above code samples are just thrown together, and only meant to get the idea across to you. Anyway, is there a better way to do this?</p>
