Understanding prototype method calls
<p>In trying to call a method on the <a href="http://marijn.haverbeke.nl/codemirror/manual.html" rel="nofollow">CodeMirror</a> javascript code editor.  I'm new to javascript and trying to understand how object oriented stuff works.  I'm having problems calling what I believe are methods.  For instance,</p>

<pre><code>var editor = CodeMirror.fromTextArea('code', options);
editor.grabKeys(function(e) { alert("Key event");});
</code></pre>

<p>This gives the <code>Uncaught TypeError: Cannot call method 'grabKeys' of undefined</code>.  Looking at the <code>editor</code> object reveals that grabKeys seems to be located at <code>editor.__proto__.grabKeys</code>.</p>

<p>How should I be thinking about this?</p>
