JavaScript class - trouble accessing public var in private method
<p>Seems like a simple problem, but can't get this to work.</p>

<p>In the example below, unselect is called but the public variable 'this.backSelected' is undefined. If I move the code of the unselect method directly into the public off method it works.</p>

<p>how would I check a public variable in a private method? I don't understand why this is nor working.</p>

<p>Thanks.</p>

<pre><code>function MyClass() 
{
    // public vars
    this.isActive = false;
    this.backSelected = false;

    // public methods
    this.on = function() {
       this.isActive = true;
       this.backSelected = true;
       // set back button on image
    }

    this.off = function() {
      this.isActive = false;
      unselect();
    }

    // private methods
    function unselect() {
        if(this.backSelected) {
           // set back button off image
        }
    };


}
</code></pre>

<p>var obj = new MyClass();
obj.on();
obj.off();</p>
