As with the map can be realized, but small white not, consult
[{completed: 0}, {momentum cargo: 15}, {non-payment: 5}, {is processing: 1}]
======="
======="
Value: [{5, name: 'not paying'}, {value: 15, name: 'momentum goods'},
{value: 1, name: 'being processed'}, {value: 0, name: 'completed'}]
CodePudding user response:
<script>
Var data=https://bbs.csdn.net/topics/[{completed: 0}, {momentum cargo: 15}, {non-payment: 5}, {is processing: 1}]
Var arr=[]
Data. The forEach (item=& gt; {
In item) for (var k {
Arr. Push ({name: k, value: item [k]})
}
})
The console. The log (arr)
</script>
CodePudding user response:
Var arr=[{completed: 0}, {momentum cargo: 15}, {non-payment: 5}, {is processing: 1}]
Var resArr=arr. The map (item=& gt; ({
Value: the Object values (item) [0],
Name: Object. Keys (item) [0]
}))
The console. The log (JSON. Stringify (resArr, null, 4))
CodePudding user response:
Could you tell me how to do, in turn, should?