title: set value in javascript class
body: <p>i wrote i a class for practicing, can anyone tell me why it print 2 instead of 1?</p>
  
  <pre><code>function hnclass(){
      var h=1;
      function print(){
          console.info(h); //here it print 1
      }
      return {
          item:h,
          printout:print
      }
  }
  
  hc=new hnclass();
  hc.item=2;
  hc.printout();
  console.log(hc.item); //here it print 2 
  </code></pre>
  
  <p>with <code>hc.item=2;</code> i am changing value of <code>item</code>, so after that, when i am calling the print function it should print out <code>2</code>. i was thinking is it possible without a setter function set value in this kind of class?</p>