How to consolidate code | making a variable Dynamic
<p>I want to loop through an object and run all functions called init().</p>

<p>I have the following code but it is repetitive.  How do I effectively make MC and Su instances of a variable?</p>

<p>Here is the repetitive code.</p>

<pre><code>MC.initAll = function() {
    for ( var key in MC ) {
        if( MC.hasOwnProperty( key ) ) {
            if( MC[key].hasOwnProperty( 'init' ) ) {
                MC[key].init();
            }
        }
    }
    for ( var key in Su ) {
        if( Su.hasOwnProperty( key ) ) {
            if( Su[key].hasOwnProperty( 'init' ) ) {
                Su[key].init();
            }
        }
    }
}
</code></pre>

<p>There are many options...</p>

<ul>
<li><p>Put them in an array and then pop them out via a for loop.</p></li>
<li><p>Make them object properties and loop through the object properties.</p></li>
<li><p>Make a function call and pass them in as parameters.</p></li>
<li><p>Use an Object Map per fritz below</p></li>
</ul>

<p>Which is best or is there a better way?</p>
