📌  相关文章
📜  javascript 从键值对创建对象 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:21.900000             🧑  作者: Mango

代码示例1
let items = 'key1:value1;key2:value2;key3:value3';
let items_array = items.split(';');
let final_items = items_array.map(item => item.split(':'));
// [ [ key1, value1 ], [ key2, value2 ], [ key3, value3 ] ]

let final_result = Object.fromEntries(final_items);
// { "key1" : "value1", "key2" : "value2", "key3" : "value3" }