js 中的Object.entries()方法返回一个给定对象自身可枚举属性的键值对
/* Demo */
const obj = {
name: 'hxx',
age: 18
};
for (let [key, value] of Object.entries(obj)) {
console.log(`${key}: ${value}`);
}
new Map()构造函数接受一个可迭代的entries,借助Object.entries() 可容易的将object转化成Map:
let map = new Map(Object.entries(obj))