I want to assign 2 different type array to eachother attribute by attribute. Can someone explain me what is the best way for this purpose? I am using the code below, but when I have too much attribute , it does not good look. How can I map attributes easily?
export interface ClassA {
Type: string;
Name: string;
}
export interface ClassB {
Typ: string;
Nm: string;
}
let items: ClassA[] = [
{ Type: 'T1', Name: 'N1'},
{ Type: 'T2', Name: 'N2'},
{ Type: 'T3', Name: 'N3'},
];
let items2:ClassB [] = [];
items.forEach((item, index) => {
let obj: ClassB = {Typ:item.Type, Nm:item.Name };
items2.push(obj);
});
console.log(items2);