title: can't you use recursive functions inside a method in typescript / javascript?
body: <p>I want to know whether why this seemingly OK code, does not work. 
  Is there something wrong going with the callback? Can you use recursive function inside a method?</p>
  
  <p>What I want to do here is, I want to call use a method inside the class <code>G964</code>, which will result something like this:</p>
  
  <blockquote>
    <p>argument: (3,5)<br>
    return result: [3,2,1,1]</p>
  </blockquote>
  
  <pre><code>export class G964 {
  public static sqInRect(l: number, w: number): number[] {
      if (l === w) { return null; }
  
    var recur = function(arr:number[]) {
      let minusResult:number = arr.slice(-2)[0] - arr.slice(-2)[1];
      if (minusResult &gt; 0) {
          arr.push(minusResult);
        recur(arr);
      } else {
          arr.shift();
        return arr;
      }
    }
  
      let testArr = [ l, w ].sort((a:number, b:number) =&gt; a-b).reverse();
  
    return recur(testArr);
  }
  }
  </code></pre>