Convery JS对数组的对象 - 保持钥匙&价值
我正在尝试将对象(更新)转换为数组(配置),同时保持相同的结构(并避免进一步嵌套)。
我尝试声明一个新的数组const并使用对象。进入键&值。 我能够获得钥匙,但是很难弄清楚如何实现阵列的嵌套。
const configArray = [];
Object.entries(updatedConfig).forEach(([key, value]) => {
configArray.push(key);
})
I am trying to convert an object (updatedConfig) to an array (configArray), while maintaining the same structure (and avoid further nesting).
I have tried declaring a new array const and using Object.entries to push the keys & values.
I am able to get the keys but am having trouble figuring out how to achieve the nesting of array.
const configArray = [];
Object.entries(updatedConfig).forEach(([key, value]) => {
configArray.push(key);
})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
object.entries
和array.map
尝试这样的尝试。You can try something like this using
Object.entries
andArray.map