提取对象的 key:value 对

提取

var obj = {x:1,y:2,z:3};
var objEntries = Object.entries(obj);
console.log(objEntries); // [[“x”,1],[“y”,2],[“z”,3]]

转换回对象

var entries = [["x", 1],["y", 2],["z", 3]];
var obj = Object.fromEntries( entries );
console.log( obj ); // {x: 1, y: 2, z: 3}

你可能感兴趣的:(Web前端)