I have a JavaScript object array which has these attributes:
[
{
active: true
conditionText: "Really try not to die. We cannot afford to lose people"
conditionType: "CONDITION"
id: 12
identifier: "A1"
superseded: false
themeNames: "Star Wars"
type here
},
{
active: true
conditionText: "Really try not to die. We cannot afford to lose people"
conditionType: "CONDITION"
id: 12
identifier: "A1"
superseded: false
themeNames: "Star Wars"
type here
}
]
I want to get only 3 attributes from there (active, condtionText, id) and create a new array.
I tried filter method and but couldn’t get the result.
Any help regarding this highly appreciated.
2
Answers
Is this what you are looking for?
you could use Array.prototype.map() – MDN Document
simple code:
Demo:
Here’s a way to do it: