title: How to access Javascript variable values outside of the function
body: <p>I've been banging my head off a brick wall with this one and another all nighter with no success. What I would like to do is have access to the values set in an array within a function but outside of that function. How could this be done? For example:</p>
  
  <pre><code>function profileloader()
  {
      profile = [];
      profile[0] = "Joe";
      profile[1] = "Bloggs";
      profile[2] = "images/joeb/pic.jpg";
      profile[3] = "Web Site Manager";
  }
  </code></pre>
  
  <p>I would then further down the page within a paragraph tag have something like:</p>
  
  <pre><code>document.write("Firstname is: " + profile[0]);
  </code></pre>
  
  <p>Obviously that would be contained with in the script tag but all i'm getting is an error on the console stating: "profile[0] is not defined".</p>
  
  <p>Anyone got any ideas where I'm going wrong? I just can't seem to figure it out and none of the other solutions I've seen when passing values from either function to function or outside of a function, have worked so far.</p>
  
  <p>Thank you to anyone who can help me with this, its probably something simple I've missed!</p>