Reputation: 11
I found some solutions but not exactly what I want. I want to get all array from object name where condition I will explain by the following example for if array=
let array = [{
"mobile1": [{
"screensize": "6.5"
}]
},
{
"mobile2": [{
"screensize": "6.5"
},
{
"price": "2000"
}]
}]
i want all array from mobile2 then final output will be
let final = [{
"screensize": "6.5"
},
{
"price": "2000"
}]
Upvotes: 1
Views: 66
Reputation: 144
Use the filter method: Array.prototype.filter() - JavaScript | MDN
const filterData = abc.filter(item => item.mobile2 )[0].mobile2
Upvotes: 2