object literal not defined unless wrapped in jQuery onready; need ideas for debugging
<p>Adopted some javascript code that I'm rearranging into smaller files to make it more managable; I'm never been a full-time javascript engineer but have worked with it for awhile but don't feel super comfortable with it. </p>

<p>I have an object literal that handles most of our controller level activities for our site. We've rearranged the code and put it in different files but there's one specific object where I'm getting an undefined error. Looking at the load order of the files, it comes in before the jQuery piece. Also wrapping this object literal in another jQuery onready wrapper fixes the problem. If I check via somethign like this:</p>

<pre><code>if (typeof arc.event_handler === "undefined"){
 alert("something is undefined");
}else{
 alert("something is defined");
}
</code></pre>

<p>then with jQuery onready wrapping, it is defined but without it is undefined. Like (I know that this code will work either with or without the jQuery onload)</p>

<pre><code>// file-1.js 
var arc={};
$(document).ready(function(){
  arc.event_handler={
    do_something: function(){
      alert('do something');
    }
  }
});
</code></pre>

<p>and then later in different file</p>

<pre><code>// later in load order z-file.js
$(document).ready(function(){
  if (typeof arc.event_handler === "undefined"){
    alert("something is undefined");  
  }else{
    alert("something is defined");
   }


  $('.some').on('click',function(){
     arc.event_handler.do_something();
  });
});
</code></pre>

<p>I'm a little bit at a loss what could causing this behavior. My understanding is that even if an external file, the part in the jQuery onready should essentially cause it to wait until these other pieces are loaded. I'm probably not getting something really simple but wanted to see if there were any ideas about what next to look at next? </p>

<p>thx in advance</p>
