Javascript `this` object == `window` in member function
<p>In some of my Javascript objects I find that my <code>this</code> pointer is correct - these are <code>new Func()</code> -type objects - when created, but in the assigned methods it can be wrong.</p>

<pre><code>function Confused() {
   console.log("checking",this==window,"is always false");
   this.method = function() {
       console.log("checking",this==window,"is true for some funcs but not others");
   };
};
</code></pre>

<p>On some calls to <code>(new Confused()).method()</code> - it seems to have lost it's <code>this</code> pointer.  The times this happen seem dependent on the function, rather than random; its something in the code around how I'm creating classes that is causing this.</p>

<p>An example is online at <a href="http://williame.github.com/barebones.js/" rel="nofollow">http://williame.github.com/barebones.js/</a> and the member callback <a href="https://github.com/williame/barebones.js/blob/d313f04dceba0b9c9125501661728e1908a2d026/g3d.js#L10" rel="nofollow"><code>G3D._file_loaded</code></a> has a wrong <code>this</code> pointer when called sometimes.</p>

<p>Why, and how do I fix it?</p>
