Typescript将对象转换为数组

Typescript将对象转换为数组,typescript,Typescript,正在尝试转换Javascript对象 const xyz = { 'fName': {type: 'string'}, 'mName': {type: 'string'}, 'lName': {type: 'string'} }; 到 看起来我今天错过了一些逻辑,在网上尝试了很多BLG,但没有得到任何结果(艰难的一天) 请有人告诉我为什么我不能转换。好了 常数xyz={ 'fName':{type:'string'}, 'mName':{type:'string'}, 'lName':{ty

正在尝试转换Javascript对象

const xyz = {
'fName': {type: 'string'},
'mName': {type: 'string'},
'lName': {type: 'string'}
};

看起来我今天错过了一些逻辑,在网上尝试了很多BLG,但没有得到任何结果(艰难的一天)

请有人告诉我为什么我不能转换。

好了

常数xyz={
'fName':{type:'string'},
'mName':{type:'string'},
'lName':{type:'string'}
};
设arr=[];
for(设k为xyz){
arr.push({[k]:xyz[k]});
}
console.log(“对象”,xyz);
console.log(“数组”,arr)请(重新)阅读并通读,特别是做你的研究,了解有关SO的相关主题,并尝试一下。如果你在做了更多的研究和搜索后陷入困境,无法摆脱困境,请发布一份你的尝试,并明确指出你陷入困境的地方。人们会乐意帮忙的。祝你好运
const arr = [
{'fName': {type: 'string'}},
{'mName': {type: 'string'}},
{'lName': {type: 'string'}}
]