现在有这样的两个数组key: ['key0', 'key1'];value: ['value0', 'value1'];
key: ['key0', 'key1']
value: ['value0', 'value1']
希望转换成以下格式[{key0: 'value0'}, {key1: 'value1'}]有什么好的办法
[{key0: 'value0'}, {key1: 'value1'}]
如果已经确定两个数组下标对应正确的话:
Object.fromEntries(key.map((k, i) => [k, value[i]]));
2.1m questions
2.1m answers
60 comments
57.0k users