Mutation Observer with External Callback Function Code
<p>I am trying to rewrite the following Mutation Observer code:</p>

<pre><code>var target = document.querySelector('div#cart');

var observer = new MutationObserver(function(mutations) {
    mutations.forEach(function(mutation) {
        console.log(mutation.type);
    });
});

var config = { childList: true, attributes: true, characterData: true, subtree: true };
observer.observe(target, config);
</code></pre>

<p>Into the script below:</p>

<pre><code>var target = document.querySelector('div#cart'), observer, moCallback, config;

moCallback = function(mutations) {
    mutations.forEach( mutation ) {
        console.log(mutation.type);
    }
};

var array = moCallback;

observer = new MutationObserver( array );

config = { childList: true, attributes: true, characterData: true, subtree: true };
observer.observe(target, config);
</code></pre>

<p>The second script is easier for me to read since it doesn't have the embedded callback function; however, I can't get it to work.</p>

<p>How can I rewrite my Mutation Observer with an external callback function instead of an inline anonymous function?</p>