gpt4 book ai didi

javascript - 数组组合重复值

转载 作者:行者123 更新时间:2023-11-28 14:52:32 25 4
gpt4 key购买 nike

我有以下数组:

Object { id: "1", name: "a", hour: "08:00:00" }  
Object { id: "2", name: "b", hour: "08:00:00" }
Object { id: "3", name: "c", hour: "08:00:00" }
Object { id: "4", name: "d", hour: "07:15:00" }
Object { id: "5", name: "e", hour: "08:00:00" }
Object { id: "6", name: "f", hour: "08:00:00" }
Object { id: "7", name: "g", hour: "09:00:00" }
Object { id: "8", name: "h", hour: "08:30:00" }

当我尝试通过以下方式访问“小时”值时:

for(i = 0; i < array.length; i++){
var hour = array[i]['hour'];
console.log(hour);
}

我得到以下结果:

08:00:00  (3 repeats) 
07:15:00
08:00:00 (2 repeats)
09:00:00
08:30:00

我怎样才能避免这种情况并得到:

08:00:00  
08:00:00
08:00:00
07:15:00
08:00:00
08:00:00
09:00:00
08:30:00

最佳答案

您正在查看浏览器正在打印的内容...您无法使用 js 更改它。这是一个依赖于浏览器的设置,在 Chrome 中只需启用时间戳即可在不同行中查看每个 console.log。

Chrome debugger - how to turn off console.log message grouping?

关于javascript - 数组组合重复值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44001867/

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