I have an object array:
source_array = [
{
"prop1":"one",
"prop2":"two",
"prop3":"three"
},
{
"prop1":"four",
"prop2":"five",
"prop3":"six"
}
]
and declaration of destination_array:
destination_array: { prop1: any, prop2: any }[];
Now I want to populate destination_array so that I only take prop1 and prop2 from source_array like this:
[
{
"prop1":"one",
"prop2":"two"
},
{
"prop1":"four",
"prop2":"five"
}
]
I tried this:
this.objectArray = new Array(this.performances.length)
this.performances.filter(item => {
this.objectArray.fill({'prop1':item.prop1, 'prop2':item.prop2})
});
but this will only return:
[
{
"prop1":"four",
"prop2":"five"
},
{
"prop1":"four",
"prop2":"five"
}
]
what am I doing wrong?