I am trying to make a parse an array by returning all the values that's in the array except for 1 property. I thought i could make use of [...] spreading but this includes all. Now that I wrote out the whole object, I worry about the future where extra properties are added to the array. is there any function in javascript that would allow me to do this? Any hints will be much appreciated!!!
// the original object
0: {
id: 1
isActive: true
isClassification: false
isEditable: true
isRequired: false
isTeamType: false
name: "Business Unit"
termGroup: {id: 1, name: "Team Classifications", isTenantWide: false, termSets: Array(0)}
termGroupId: 1
termGroupName: "Team Classifications"
terms: (3) [{…}, {…}, {…}]
}
// my parsing code
// args:
// @return {array} - returns an array containing the termsets only.
getTermSets() {
console.log(this._termSetsWithChilden);
return this._termSetsWithChilden.map(termSet => {
return {
id: termSet.id,
isActive: termSet.isActive,
isClassification: termSet.isClassification,
isEditable: termSet.isEditable,
isRequired: termSet.isRequired,
isTeamType: termSet.isTeamType,
name: termSet.name,
termGroupId: termSet.termGroupId,
termGroupName: termSet.termGroupName,
numberOfTerms: termSet.terms.length
};
});
}
// my retun value
0: {
id: 1
isActive: true
isClassification: false
isEditable: true
isRequired: false
isTeamType: false
name: "Business Unit"
numberOfTerms: 3
termGroupId: 1
termGroupName: "Team Classifications"
}
deletethe one you don't want.