title: TypeScript Array: .map() is not a Function
body: <p>I searched for another question like this, but 99% of the other questions are dealing with an Observable, which I'm not. I have code that looks like this:</p>
  
  <pre><code>selectedItems: Item[] = null;
  selectedDate: Date = null;
  
  submitItems() {
      const itemObservables = this.selectedItems.map(item =&gt; {
          item.date = this.selectedDate;
          return this.itemService.putMovedItems(item)
      });
  
      return forkJoin(itemObservables);
  }
  </code></pre>
  
  <p>In VSCode, there are no linter errors; this should be valid code. However, at runtime I get "TypeError: selectedItems.map is not a function". </p>
  
  <p>When I debug, I notice that this.selectedItems says:</p>
  
  <pre><code>Object {0: Item, 1: Item, 2: Item, ...}
  </code></pre>
  
  <p>This caused me to suspect that when the property is set, it's not being set as an actual Array. So, I tried to cast by doing:</p>
  
  <pre><code>const items = &lt;Array&lt;Item&gt;&gt;this.selectedItems;
  </code></pre>
  
  <p>and then do the map on <code>items</code>, but I got the same runtime error. I'm not sure what's going on here.</p>
  
  <p>Edit: For clarity's sake, <code>selectedItems</code> is set in the ngOnInit():</p>
  
  <pre><code>ngOnInit() {
      const selectedItems = this.itemService.selectedItems.getValue();
      this.selectedItems = {...selectedItems};
  }
  </code></pre>
  
  <p><code>this.itemService.selectedItems</code> is a <code>BehaviorSubject&lt;Item[]&gt;</code>.</p>