【发布时间】:2023-03-15 22:17:01
【问题描述】:
对不起,如果这有点令人困惑,但我有这个数组:
[
{
name: 'id',
type: 'string',
primary: true
},
{
name: 'notes',
type: 'text',
default: '[]'
},
{
name: 'reminders',
type: 'text',
default: '[]'
}
]
我怎么把它变成
{
notes: '[]',
reminders: '[]'
}
?逻辑如下:任何具有default属性的索引,将新对象中的键设置为索引的name,并将值设置为索引的default。
【问题讨论】:
标签: javascript arrays node.js object