- 此问题在此处已有答案**:
Convert object to an array of objects?(5个答案)
get Array-Object-String thing from the given Object(4个答案)
How to convert object A to an array of objects with object A's properties and assign value and label to them [duplicate](2个答案)
6小时前关门了。
我有一个目标
const myObject = {rice : 10, wheat: 20, sugar: 3}
我想把它转换成一个对象数组:
myArray = [
{"product" : rice, "QTY" : 10},
{"product" : wheat, "QTY" : 20},
{"product" : sugar, "QTY" : 3}
]
帮帮忙。谢谢。
1条答案
按热度按时间4uqofj5v1#
这就是
Object.entries
、destructuring和shorthand property names可以提供的服务: