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.