explain javascript: value assignment fails
<pre><code>var sc = new stuCore();
function stuCore() {
    this.readyPages = [];
    this.once = true;
    var self = this;

    // gets called asynchronously
    this.doPrepPage = function (page){

            if(self.once == true){
                   // still gets executed every time, assignment fails
                   self.once = false;
                   doSomeStuffOnce();
            }
    };

   this.addReadyPage = function (pageid) {

            console.log("readypage called");
            this.readyPages.push(pageid);
            if (!$.inArray(pageid, self.readyPages) != -1) {
                    this.doPrepPage(pageid);
            }
    };


}
</code></pre>

<p>why does this assignment fail? I thought I knew the basics of js, but I'm stumped by this. And furthermore what would be a possible solution? call a constructor first and set the variable there?</p>

<p><strong>EDIT:</strong> 
gets called like this in some other script:</p>

<pre><code>  sc.addReadyPage(self.id);
</code></pre>
