title: Cannot access global variable in typescript
body: <p>I have a weird problem in the code. I declared markers variable inside a class so it is global and can be accessed everywhere inside class. But the problem is that I can access markers inside initMap but cannot access it inside function of InitMap. Error tells: TS2339 Property 'markers' does not exist on type void</p>
  <pre><code> export class StudentGraphicReportMapComponent implements OnInit  {
    locations: any[] = [];
    markers:any[] = [];
    constructor(private http: Http, private  elementRef: ElementRef , private dashboardService: DashboardService) {
    }
    initMap() { 
     // ------ CAN ACCESS markers here
   
      this.locations.forEach(function(location: Location) {
           for ( let b = 0; b &lt; location.studentCount; b++) {
             let marker = new google.maps.Marker({
               position: location,
               label: 'A'
             });
      // ----------CANNOT ACCESS markers here
             this.markers.push(marker); //Error:Property 'markers' does not exist on type void
           }
      });
    
    }
    ngOnInit() {
      this.dashboardService.getStudentCoordinates().then(data =&gt; {
        this.locations = data.data;
        this.initMap();
      });
    }
  
  }
  </code></pre>
  <p>Please help me to solve this problem. Kind regards</p>