title: Use variable of one function in another (Three.js) Javascript
body: <p>I had loaded an obj file using three.js
  I tried acquring its vertex 'X' position and save it in 'pos' inside the objloader function which is in the init() function. 
  I want to use the variable's value in another function say displayposition()
  when I try</p>
  
  <pre class="lang-js prettyprint-override"><code>var pos;
  
  function init() {
      var objLoader = new THREE.OBJLoader();
      objLoader.load('objectfile.obj', function(object) {
          scene.add(object);
          pos = scene.children[5].children[0].geometry.attributes.position.getX(0);
          console.log(pos); //This displays the vertex position value
      });
  }
  
  function displaypos() {
      console.log(pos); //It doesn't display the vertex position value
  }
  </code></pre>
  
  <p>How to make it global and make the  variable value of 'pos' usable throughout the  program..</p>