const tweets = [
{
id: 1080777336298049537,
message: "Hello Twitter 👋",
created_at: "2020-01-03 11:46:00"
},
{
id: 1080777336298195435,
message: "How do you keep track of your notes?",
created_at: "2021-02-19 15:32:00"
}
];
const messages = tweets.map(tweet => tweet.message);
console.log(messages);// ["Hello Twitter 👋", "How do you keep track of your notes?"]
.map()を使うことでArray of objectsからStringのArrayやNumberのArrayを作ることができます。
Arrays of objectsから別のArray of objectsを作ることもできます。
コメントを書く