title: object variables in JavaScript
body: <p>I have the following code:</p>
  
  <pre><code>WaitModel = -&gt;
    timesDelayed = 0
    maxDelay = 10
  
    return this
  
  WaitModel.prototype =
    wait: -&gt;
      console.log 'waiting'
  
      console.log this.timesDelayed, this.maxDelay
  
      if this.timesDelayed &gt;= this.maxDelay
        console.log 'running'
        this.timesDelayed = 0
  
      else
        this.timesDelayed++
        setTimeout this.wait, 1000
  
      return
  
  new WaitModel().wait()
  </code></pre>
  
  <p>I think this should produce output like:</p>
  
  <pre><code>waiting
  0 10
  waiting
  1 10
  ...
  </code></pre>
  
  <p>But instead it produces output like:</p>
  
  <pre><code>waiting
  0 10
  waiting
  undefined undefined
  </code></pre>
  
  <p>Where am I unsetting <code>this.timesDelayed</code> and <code>this.maxDelay</code>? Am I misunderstanding the way to make objects here?</p>