I have an array of objects like so:
const content = [
{
title: 'Morning run',
id: 'id1',
desc: 'Meet at the park',
date: '2018-01-14T09:00:00.000Z',
location: 'Central park',
createdBy: '23432432',
},
{
title: 'Evening run',
id: 'id2',
desc: 'Meet by the station',
date: '2018-01-14T18:00:00.000Z',
location: 'Central station',
createdBy: '23432432',
},
];
How can I create an associative array like so?:
const output = {'id1' : 'Morning run', 'id2' : 'Evening run'}
这可以使用map函数完成吗?
output
表示法实际上是一个对象。请注意,我的翻译没有改变原意,同时使内容更加易懂。 - rolfv1