How can I access a data from another object in Javascript?
<p>I want to access availJobs in jobs.scan object but I couldn't. It is not defined in jobs.attack. What can I do to access the part of jobs.scan in other objects?</p>

<pre><code>var jobs = new Array();

jobs.scan = function() {
    var availJobs = new Array();
    var jobContents = dom.get("app8743457343_content");
    var boldthreads = jobContents.getElementsByTagName('b');
    for(var i = 0; i &lt; boldthreads.length; i++) {
        if(boldthreads[i].style.color == 'silver') {
            availJobs.push(boldthreads[i].textContent);
        }
    }
    return availJobs;
}

jobs.attack = function() {
    jobs.scan();
    alert(jobs.availJobs[0]);
}

jobs.attack();
</code></pre>

<p>availJobs[0] in jobs.attack doesn't work. It's undefined. How can I set the availJobs as public and can be accessed in other objects?jav</p>

<p>Thanks for all the help!!
Here's the code that I put:</p>

<pre><code>var jobs = {
    availJobs: new Array(),
    scan: function() {
        var jobContents = dom.get("app8743457343_content");
        var boldthreads = jobContents.getElementsByTagName('b');
        for(var i = 0; i &lt; boldthreads.length; i++) {
            if(boldthreads[i].style.color == 'silver') {
                this.availJobs.push(boldthreads[i].textContent);
            }
        }
    },
    attack: function() {
        this.scan();
        alert(this.availJobs[0]);
    },
};

jobs.attack();
</code></pre>

<p>This code is definitely more elegant don't you think? I used this and it worked!</p>
