title: Javascript Object method scope - method fails
body: <p>Method of object fails, but property logs fine.
  So I declare a variable in the global scope, and try to assign an object to it within a function. The property 'id' traces correctly, but the method causes an error. I've looked for a similar post to this, but cannot find anything.</p>
  
  <p>I'd rather program using OO in Javascript so it would be great if you could give me a pointer for this issue. Thanks in advance.</p>
  
  <pre><code>var currentEnemyPieceObject; // this gets set in the play function
  
  function EnemyPieceObject( _id ){
  
    this.id = _id;
    this.pathArray = [];
    this.active = false;
  
  }
  
  EnemyPieceObject.prototype = {
  
    constructor:EnemyPieceObject,
    addPointToPathArray:function( xPos, yPos ){ 
      var point = { "x":xPos, "y":yPos };
      this.pathArray.push( point );
    }
  }
  
  
  function play() {
  
    currentEnemyPieceObject  =  new EnemyPieceObject( 0 );
  
    console.log( currentEnemyPieceObject.id ); // result is 0
  
    currentEnemyPieceObject.addPointToPathArray( 0, 0 );
    // results in error
    // Uncaught TypeError: Uncaught TypeError:
    // currentEnemyPieceObject.addPointToPathArray is not a function
  
  }
  </code></pre>