Scope of Variables declared within javascript object
<p>I was trying to understand the scope of variables in javascript objects. But the behavior that I am getting seems to be a little off the road. To put it simply, if I have an object that defines a function as a variable, then the function variable is not able to access other variables of the object in which it is defines. The code below will make things clear.</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
    &lt;script type="text/javascript"&gt;

        var someObject = {
            someVariable : 5,
            getVariable: function() {
                return someVariable;
            }
        };

        window.onload = function () {
            alert(someObject.getVariable());
        };

    &lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    Hello There
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>The above code gives <strong>"ReferenceError: someVariable is not defined"</strong> for the someVariable in function getVariable(). Would anyone like to comment on this behavior?</p>
