LoginSignup
0
0

More than 1 year has passed since last update.

javascript 深い配列から取得

Posted at
data =[{
    id:1,
    value:['a', 'b', 'c']
  },
  {
    id:2,
    value:['d', 'e', 'f']
  },
  {
    id:3,
    value:['g', c', 'h']
  },
]

'c'のみを取得したいと思います。

let r = data.map(d =>{
  return d.value
})
.flat()
.filter(v=> v === 'c')

console.log(r)
// [ 'c' ,  'c' ]

できました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0