【问题标题】:React new Set method how can access the value?React new Set 方法如何访问值?
【发布时间】:2021-09-25 03:33:47
【问题描述】:

我正在使用 react,如何访问这两个值?有人帮忙吗?

var names = messages.map(function(item){
     return item.sender.title
    
    })
    let uniqueChars = [...new Set(names)];

result of console.log here

console.log(uniqueChars[0]);

【问题讨论】:

    标签: javascript arrays reactjs object set


    【解决方案1】:

    您可以使用地图功能访问它。

    uniqueChars.map(item => {
      console.log(item)
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-04-19
      • 2019-08-14
      • 2020-04-01
      • 1970-01-01
      • 2022-06-28
      • 1970-01-01
      • 2018-10-31
      相关资源
      最近更新 更多