title: calling Object Method gives "Uncaught TypeError: is not a function" error
body: <p><strong>Problem:</strong>
  Calling (<code>console.log(d.yakinlik.uzak.X1())</code>) this function</p>
  
  <pre><code>function Div(isim) {
      this.loc = document.getElementById(isim);
      this.getStyle = function (stili) {
          return window.getComputedStyle(this.loc).getPropertyValue(stili);
      };
      this.getIntStyle = function (stili) {
          return parseInt(this.getStyle(stili), 10);
      };
      this.yakinlik = {
          uzak: {
              X1: function () {
                  return this.getIntStyle('left');
              }
          }
      };
  }
  </code></pre>
  
  <p>gives </p>
  
  <blockquote>
    <p>Uncaught TypeError: this.getIntStyle is not a function</p>
  </blockquote>
  
  <p>I have tried using:</p>
  
  <pre><code>    this.yakinlik = {
          uzak: {
          },
          orta: {
          },
          yakin: {
          },
          cokyakin: {
          }
      };
      this.yakinlik.uzak.X1 = function () { return this.getIntStyle('left'); };
  </code></pre>
  
  <p>but it failed too. But when I do not use a method here <code>this.yakinlik.uzak.X1 = function () { return this.getIntStyle('left'); };</code> like this <code>this.yakinlik.uzak.X1 = this.getIntStyle('left');</code> it works (actually it gives NaN, but it is normal because it hasn't recomputed, so I have to use a method there. ).</p>
  
  <p>Here is the involved pieces of the code:</p>
  
  <pre><code>'use strict';
  function Div(isim) {
      this.loc = document.getElementById(isim);
      this.getStyle = function (stili) {
          return window.getComputedStyle(this.loc).getPropertyValue(stili);
      };
      this.getIntStyle = function (stili) {
          return parseInt(this.getStyle(stili), 10);
      };
      this.yakinlik = {
          uzak: {
          },
          orta: {
          },
          yakin: {
          },
          cokyakin: {
          }
      };
      this.yakinlik.uzak.X1 = function () { return this.getIntStyle('left'); };
  }
  
  function getRandomInt(min, max) {
      return Math.floor(Math.random() * (max - min + 1)) + min;
  }
  
  
  
  var d = new Div("d");
  d.loc.style.left = getRandomInt(0, window.innerWidth - 50) + "px";
  d.loc.style.top = getRandomInt(0, window.innerHeight - 50) + "px";
  console.log(d.yakinlik.uzak.X1() + " " + d.getIntStyle('top'));
  </code></pre>
  
  <p>How can I fix this without having to use a property there?</p>
  
  <p>Thanks.</p>