How do self referenced objects work in JavaScript function?
<p>I am trying to set up a javascript object with one of it's items being a function. I am doing a little bit of self reference and it is not working. </p>

<pre><code>var onTimePoints = function($a, $b, $c, $lifeotr){

    $var1 = ($b - $a) / $c;
    $var2 = ($lifeotr - $a) / $var1;
    if($var2&gt;$c)
    {
    $var2 = $c;
    }
    if($var2&lt;0)
    {
    $var2 = 0;
    }
    $var2 = Math.round($var2);
    return $var2;
}
var lifeData ={
      min: 25000,
      max: 65000,
      otr: 56426,
      maxPoints:100,
      otp: onTimePoints(25000, 65000, 100, 56426),
      test: function(){
        alert(this.min);
      }
}
</code></pre>

<p>When I do <code>conosle.log(lifeData.otp)</code> it works. </p>

<p>When I replace the hard coded numbers with <code>this.min</code>, <code>this.max</code>, etc... it doesn't work. </p>

<p>Here is an example of what doesn't work:</p>

<pre><code>var lifeData ={
  min: 25000,
  max: 65000,
  otr: 56426,
  maxPoints:100,
  otp: onTimePoints(this.min, this.max, this.maxPoints, this.otr),
  test: function(){
    alert(this.min);
  }
}
</code></pre>

<p>In this case <code>console.log(lifeData.otp)</code> returns <code>NaN</code>.</p>

<p>I am sure that I am just overlooking something. Appreciate if you know the issue.  </p>
