I am trying to fetch data (Array of objects) from ngrx Store and assign to an array using subscribe option provided by Observables in Angular 2, but the issue is when I try to read the contents of the array. Following is a snippet of code ->
 metaData$: Observable<MetaClassDefinition[]>;
    myArray: MetaClassDefinition[] = [];  
    constructor(private store: Store<fromRoot.State>) {
      this.metaData$ = store.select(fromRoot.getMetadata);
    }
    this.metaData$.subscribe(
       data => {
          if (data.length > 0) {
             // Deep copy array
             data.forEach(v => this.myArray.push({...v}));
          }
       },
       error => { console.log(error)}
    );
    console.log(this.myArray);  //-------(1)
    console.log(this.myArray.length);   //-------(2)
Now, 1st console.log prints the array of objects like this ->
But, we i try to print 2nd console.log, I get the size of the array as zero. Is there something that I am missing out here?

 
     
     
    