数组索引可以是数组吗?

时间:2022-06-21 22:29:55

first i wanna sorry for my english. ya, its very bad. so. lets go: i've this obj:

首先,我想抱歉我的英语。啊,非常糟糕。所以。我们走吧:我有这个对象:

estrutura = {  
 //tags 
 div : { 

      //subtags
      id:'page',
      classe:'container_12 ',

      conteudo: {
          esqueda: {
             //childSubTags
            id:'divMenuVertical',
            classe:'grid_3',
            conteudo : 'Ola, sou um grid de 3 colunas'
          },
            centro: {
            id:'divConteudo',
            classe:'grid_5',
            conteudo: 'ola, sou um grid de 5 colunas'
         },
          direita: {
            id:'divConteudo',
            classe:'grid_3',
            conteudo: 'Ola, sou um grid de 3 colunas'
          }
      }
  }

}

}

but when i try do something like:

但当我尝试做类似的事情:

Array.isArray(estrutura[0]) 

returns the index isn't a array. why? i'm trying make a recursive searching. someone could helpe me please?

返回索引不是数组。为什么?我正在尝试进行递归搜索。有人可以请我帮忙吗?

1 个解决方案

#1


1  

it is not array because it is object. Everything in javascript are objects. You should create array like this: var myArray = new Array();

它不是数组,因为它是对象。 javascript中的所有内容都是对象。你应该像这样创建数组:var myArray = new Array();

#1


1  

it is not array because it is object. Everything in javascript are objects. You should create array like this: var myArray = new Array();

它不是数组,因为它是对象。 javascript中的所有内容都是对象。你应该像这样创建数组:var myArray = new Array();