私は配列person
を3つのオブジェクトとフォームを持っています。description
という名前のオブジェクトを返したいと思います。今度はマップを使ってperson
を繰り返しますが、ここでは、description
がない場合はundefined
を返します。私は最後にdescription
オブジェクトだけを持つ配列を取得したい(未定義ではない)。空でないオブジェクトの配列を返します
const person = [
{abc: 'abc',description:{}},
{qwe:'qwe', def:'def'},
{abcd: 'abcd',description:{}}
]
console.log(person.map(indivi => indivi.description))
をmap' '前に' filter'を追加... –