gpt4 book ai didi

javascript - React中map函数的数组

转载 作者:行者123 更新时间:2023-11-28 14:09:41 24 4
gpt4 key购买 nike

我正在尝试将 map 用于像这样的 array 。我无法预测名称,并且没有公共(public)键 - 只是名称值对,它们可以不同

{"name":"Text","description":"Text","some other item":"Text"}

我尝试了各种方法,但大多数方法都需要某种标识符。很高兴了解如何解决这个问题。

最佳答案

您可以使用对象转换:

Object.values(values).map(e => console.log(e)); //to get a map of the values
Object.keys(values).map(e => console.log(e)); //to get a map of the keys
Object.entries(values).map(e => console.log(e)); //to get a map of [key, value]

您可以检查这些对象映射 with a live demo herea documentation here

关于javascript - React中map函数的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60008441/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com