title: Document.ready with/without function, and adding an array to existing code
body: <p>I think this is a really newbie question so thank you for helping me learn. I'm trying to implement a client side Google Analytics experiment am following the steps <a href="https://developers.google.com/analytics/solutions/experiments-client-side" rel="nofollow">here</a>.  </p>
  
  <p>I have always used document.ready like this</p>
  
  <pre><code>$( document ).ready(function() {
    // Handler for .ready() called.
  });
  </code></pre>
  
  <p>and the instructions here recommend this (without <em>function</em>):</p>
  
  <pre><code>$(document).ready(
    // Execute the chosen view
    pageVariations[chosenVariation]
  );
  </code></pre>
  
  <p>I have a few other functions I want to call on the same page outside of the experiment but when I try to combine them into one document.ready, the google analytics experiment will not run.  So I have two questions:</p>
  
  <ol>
  <li><p>When is it OK not to include <em>function</em> with document.ready? Looking at the documentation <a href="https://api.jquery.com/ready/" rel="nofollow">here</a>, I don't ever see it written without function so not I'm not clear on this</p></li>
  <li><p>What is the correct way to add <code>pageVariations[chosenVariation]</code> to my existing document.ready?  I have tried adding it to my code as shown below but the experiment only works if it is inside its own, separate document.ready. </p>
  
  <pre><code>        &lt;script&gt;
              var chosenVariation = cxApi.chooseVariation();
              var pageVariations = [
                function() {
                  console.log('variation one');
                }, 
                function() { 
                  document.getElementById('hero').src = 'heroB.jpg';
                  document.getElementById('oval').src = 'es_03b.jpg';
                  console.log('variation two');
  
                }
              ];
              $(document).ready(function () { 
                  pageVariations[chosenVariation];
                  about();
                  truck();
                  $("#vid").click(function() {    
                      $.fancybox({
                          autoSize: false,
                          inline:true, 
                          height: 456,
                          width: 700,
                          href:"#cab"
                          });
                      }); 
              });         
          &lt;/script&gt;
  </code></pre></li>
  </ol>