I have used web3.eth.abi.decodeParameters and returned values have been pushed into my array (finalGettersParams.push(...)) something like this.

   [ Result { __length__: 0 },
  Result {
    '0': '0x0000000000000000000000000000000000000000',
    __length__: 1 },
  Result {
    '0': '0x0000000000000000000000000000000000000000',
    '1': '0x0000000000000000000000000000000000000000',
    __length__: 2 } 

Now i want to access individual elements of "Result"from my array. I can access finalGettersParams[2].__length__ and its print 2. However, i am not sure how to access the '0' and '1' .... like this finalGettersParams[2].'0' These 0, 1 are dynamic.. means they can be increased 0, 1, 2, 3 or decreased (depending on my arguments list, you can see in above array)


This is a general Javascript question (not specifically related to Ethereum).

Instead of this:


Use this:

|improve this answer|||||
  • sorry, i was also thinking so, but could not find the exact term for this scenario.. thanks for your time...... – Amir Ali Dec 18 '19 at 7:00
  • @AmirAli: You're welcome, no need to apologize for anything here (I just wanted to emphasize that the problem was not Ethereum-related). – goodvibration Dec 18 '19 at 7:01
  • Thanks again...... one more question, I am not sure should I make another question or in this comment will be OK ? Because it's a extension of this question ... is it possible to give all parameters ('0', '1', ...) of above mentioned finalGettersParams array to my myContractInstance.methods[myFunc](...finalGettersParams[j]).call({from: account1})... f – Amir Ali Dec 18 '19 at 7:15
  • @AmirAli: What's your function's prototype? – goodvibration Dec 18 '19 at 7:24
  • i think, now it does't matter... because now i have function name/methodID and their parameters (in above forms) ... can i use this information to call getters without knowing its prototype.. ? – Amir Ali Dec 18 '19 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.