Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

93
Visualizações
Array of key/value pairs?

I'm working with ethers.js and fetching data from a smart contract. When logging the response to the console, something along the lines of this gets logged:

0: BigNumber {_hex: '0x05', _isBigNumber: true}
1: "test test test"
2: "transfer(address, uint256)"
3: "data data data"
4: BigNumber {_hex: '0x01', _isBigNumber: true}
5: BigNumber {_hex: '0x61a4e4ae', _isBigNumber: true}
6: false
contractAddress: "test test test"
functionSignature: "transfer(address, uint256)"
id: BigNumber {_hex: '0x05', _isBigNumber: true}
params: "data data data"
voteAmount: BigNumber {_hex: '0x01', _isBigNumber: true}
voteFinishTimestamp: BigNumber {_hex: '0x61a4e4ae', _isBigNumber: true}
voteFinished: false

So it looks like the data is logged twice, once with the indices and then once more as key/value pairs. I'm extremely confused as to how this works. When Array.isArray() is called on this data structure, it returns true, yet it allows accessing the properties both through indices and through dot notation. So, data[6] will return the same thing as data.voteFinished. I don't understand what this array/object hybird is and how it's possible to access array properties through dot notation in this specific scenario. Any clarification would be great.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda