title: How can I assign global and local variables in node js
body: <p>If I declare a variable and assign value from a method and print outside the method.But it shows undefined.
  My code is,</p>
  
  <pre><code>var value;
  var getValue = function getValue(){
      value = 5;
  };
  console.log(value); 
  </code></pre>
  
  <p>Output,</p>
  
  <pre><code>undefined
  </code></pre>
  
  <p>I am also trying in global variable</p>
  
  <pre><code>var getValue = function getValue(){
      global.value = 5;
  };
  console.log(value);
  </code></pre>
  
  <p>But shows some errors,</p>
  
  <pre><code>console.log(value);
              ^
  
  ReferenceError: value is not defined
      at Object.&lt;anonymous&gt; (~/MyApp/test.js:8:13)
      at Module._compile (module.js:413:34)
      at Object.Module._extensions..js (module.js:422:10)
      at Module.load (module.js:357:32)
      at Function.Module._load (module.js:314:12)
      at Function.Module.runMain (module.js:447:10)
      at startup (node.js:146:18)
      at node.js:404:3
  </code></pre>