gpt4 book ai didi

javascript - 未捕获的类型错误 : Cannot read property 'keys' of undefined

转载 作者:行者123 更新时间:2023-11-30 09:15:05 25 4
gpt4 key购买 nike

我的控制台中有这些数据。

enter image description here

var uniqVisitorDeviceType = visitorDeviceType.reduce((acc, val) => {
acc[val] = acc[val] === undefined ? 1 : acc[val] += 1;
return acc;
}, {});
console.log(uniqVisitorDeviceType)

我试图只访问数组键。

我试过了

console.log(uniqVisitorDeviceType.prototype​.keys())

我得到了

Uncaught TypeError: Cannot read property 'keys' of undefined

如何进一步调试它?

最佳答案

您有一个对象,而不是一个数组。使用 Object.keys(uniqVisitorDeviceType)相反。

关于javascript - 未捕获的类型错误 : Cannot read property 'keys' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55697075/

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