gpt4 book ai didi

javascript - 数组长度不起作用

转载 作者:行者123 更新时间:2023-11-30 07:16:42 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Array length undefined

我有以下数组,但每当我尝试使用 categoryData.length 找出长度时,它只会给我 undefined。如果我输入 console.log(categoryData),它会给我数组中的所有对象。

var categoryData = {
animals: {
name: "Animals",
description: "All your favorites from aardvarks to zebras.",
items: [
{
name: "Pets"
},
{
name: "Farm Animals"
},
{
name: "Wild Animals"
}
]
},
colors: {
name: "Colors",
description: "Fresh colors from the magic rainbow.",
items: [
{
name: "Blue"
},
{
name: "Green"
},
{
name: "Orange"
},
{
name: "Purple"
},
{
name: "Red"
},
{
name: "Yellow"
},
{
name: "Violet"
}
]
},
vehicles: {
name: "Vehicles",
description: "Everything from cars to planes.",
items: [
{
name: "Cars"
},
{
name: "Planes"
},
{
name: "Construction"
}
]
}

};

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