Run code on variable initialization
<p>I just learned this way of initializing a variable in javascript:</p>

<pre><code>var MyGlobalVar = {
    Property1 : 1,
    Property2 : "Two"
}
</code></pre>

<p>Which is pretty neat because is a lot <em>like</em> a static object. But is there any way I can run initialization code inside it, kinda like a static constructor would do?</p>

<p>How about using <code>eval</code>, such as <code>Property1 : eval("[code to run here...]");</code>?</p>

<p>I just don't want to put any initialization or part of my object's definition outside the object itself (outside the brackets).</p>

<p><strong>Edit</strong>: My initialization code would actually return a filled up array, so <code>Property2</code> would be this array. But I don't want to recreate this array every time is needed.</p>
