Object.keys(obj) -----根据对象的键形成的数组
Object.entries(obj) ---- 根据对象的键值对形成的数组
Object.values(obj)----根据对象的值形成的数组
var obj ={"A": "阿根廷",
"B": "巴西",
"C": "智利"}
Object.entries(obj)
Object.keys(obj)
Object.values(obj)
var obj ={"A": "阿根廷",
"B": "巴西",
"C": "智利"}
let arry=Object.values(obj)
let newArry=Object.keys(obj).map((item,index,ary)=>{
return {
value:item,
label:arry[index]
}
})
console.log('Object.entries(obj) :>> ', newArry);