title: JavaScript Namespaces + Setter
body: <p>Well, I'm using object orientation in JavaScript, but instead of using <code>new</code>, I just call the method from the namespace. In the moment, I have the following code:</p>
  
  <pre><code>var Component = {
      Button: function(_text, use_image) {
          button = $.createElement('button')
          if (use_image != false)
          {
              button.innerHTML = _text;
          }
          else
          {
              button.innerHTML = _text
          }
          var text = _text
          return button
      }
  }
  </code></pre>
  
  <p>When I want to return a button, I do:</p>
  
  <pre><code>x = Component.Button("Click me")
  </code></pre>
  
  <p>And after I can use x. But if I want to change the text of x, I must use <code>x.textContent</code>. I'd like to instantiate this and use a setter to apply its text, this way:</p>
  
  <pre><code>x = new Component.Button("Click me")
  x.text = "Don't click me"
  document.getElementsByTagName("body")[0].appendChild(x)
  </code></pre>
  
  <p>And if I try to apply the setter <code>text</code>, it becomes global, I want to have a unique for each button. Mix namespaces with get/set.</p>
  
  <p>Thank you in advance</p>