title: Typescript/Angular: Filter array of objects
body: <p>I have an array of objects.My object has a "category" attribute. I want to filter the array of objects to return only objects with the "tech" category".</p>
  
  <p>The error being thrown is "filter" does not exist on type {}</p>
  
  <p><strong>stocks-list.ts</strong></p>
  
  <pre><code>import { Stock } from './Stock';
  
  export const STOCKS: any[] = [
    { id: 11, symbol: 'AAPL', name: 'Apple', category: 'Tech' },
  ];
  </code></pre>
  
  <p><strong>stock.service.ts</strong></p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { Stock } from './Stock';
  
  import { STOCKS } from './stocks-list';
  
  @Injectable({
    providedIn: 'root'
  })
  
  
  export class StockService {
  
  
    constructor() { }
    techStocks: Stock[];
    getTechStocks(): Stock[] {
      this.techStocks = STOCKS;
  
  
      return this.techStocks.filter(xx =&gt; xx.category = 'Tech');
    }
  }
  </code></pre>