1

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"
}]

1 Answer 1

2

Use the filter method: Array.prototype.filter() - JavaScript | MDN

const filterData = abc.filter(item => item.mobile2 )[0].mobile2
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.