title: Why Array reference assignation is not working in typescript?
body: <p>I am working on an application and I have one service and an component file(typescript file of a component in angular). What I am doing is performing search from IndexedDB(Browser) and assigning to Array of type any, but It is not working, code is given below:</p>
  
  <p>Service typescript file:</p>
  
  <pre><code>// taking a empty array of type any
  searchedHistoryArr = [];
  
  // calling method from component typescript file  
  searchHistoryFromIndexDb(): any[] {
  
    this.indexService.getAll('search', (data) =&gt; {
      if (data)
        for (let i = 0; i &lt; data.length; i++) {
          this.searchedHistoryArr.push(data[i]);
        }
  
      //console.log(data);
  
    });
  
    return this.searchedHistoryArr;
  }
  </code></pre>
  
  <p>Component file : This file has some method and a line of code is written below.</p>
  
  <pre><code>historyArray=[];
  // calling the method of service typescript file
  this.historyArray= this.searchService.searchHistoryFromIndexDb()
  </code></pre>
  
  <p>Expected behaviour as per me: historyArray must have reference of returned 
   value;
   But HistoryArray still has length zero.</p>