title: get variable inside the function
body: <p>hello i'm new in javascript I just want to ask if it is possible to get the value inside a function?</p>
  
  <p>sample code</p>
  
  <pre><code>function a(){
    var sample = "hello world"
  };
  </code></pre>
  
  <p>then i will go to the global context and get the variable <code>sample</code></p>
  
  <pre><code>sample2 = sample
  console.log(sample2);
  </code></pre>
  
  <p>And when i console.log sample2 then the value of sample2 should be "hello world" please share your knowledge i want to learn more in javascript thanks in advance</p>