title: How to pass array of objects to Class in Typescript
body: <pre><code>export interface ICars{
      carType?: string;
      carColors: string[];
  }
  
  export class Cars implements ICars{
      carType?: string;
      carColors: string[];
  
      constructor(data?: ICars){
          //here code is present to set the carType and car Color parameters.
      }
  }
  </code></pre>
  
  <p>And I am calling the above class from my react component as below.</p>
  
  <pre><code>const carTemplate: Cars = new  Cars({
      carType: myUseStateObjForCars,
      carColors: myUseStateArrayForCars,
  })
  </code></pre>
  
  <p>My html is as follows</p>
  
  <pre><code> const [myUseStateObjForCars, setMyUseStateObjForCars] = useState(0);
   const [myUseStateArrayForCars, setMyUseStateArrayForCars] = useState(0);
  
  &lt;input onChange={e=&gt; setMyUseStateObjForCars(e.target.value)}
  &lt;input onChange={e=&gt; setMyUseStateArrayForCars(e.target.value)}
  </code></pre>
  
  <p>This works fine when I have an Cars as a single object.
  How can I achieve the same when I have to pass array of object to my Car class. Without modifying my class Cars by using any for loop or map to set every object inside my Cars class? 
  I am using react hooks,Redux, RxJS and typescript.</p>
  
  <p>Is this possible or am I doing something wrong here?
  Any help on this would be appreciated as I am new to react.js , hooks and typesciprt.</p>
  
  <pre><code>[
      {
          carType: "4wheeler";
          carColors: ["red", "green"];        
      },
      {
          carType: "2wheeler";
          carColors: ["pink", "yellow"];  
      }
  ]
  </code></pre>