Here are my codes:
var overallBlockList = Array();
var blockListArray = Array();
$.each(data.blockList, function( key, value ) {
blockListArray['blockNumber'] = value.blockNumber;
blockListArray['age'] = value.age;
blockListArray['txn'] = value.txn;
blockListArray['uncles'] = value.uncles;
blockListArray['miner'] = value.miner;
blockListArray['gasUsed'] = value.gasUsed;
blockListArray['gasLimit'] = value.gasLimit;
blockListArray['avg.GasPrice'] = value['avg.GasPrice']['value'] + " " + value['avg.GasPrice']['unit'];
blockListArray['reward'] = value['reward']['value'] + " " +value['reward']['unit'];
overallBlockList[] = blockListArray; // In php, the overallBlockList Key will auto generate numeric. how about in Js syntax?
});
I wish to get the below one. the overallBlockList will have the numeric key with blockListArray data. But the overallBlockList[] = blockListArray; is php syntax. how about for javascript syntax in order to generate numeric key of overallBlockList?
[overallBlockList] => Array
(
[0] => Array
(
[blockNumber] => 6764218
[age] => 1573608431
[txn] => 30
[uncles] => 0
[miner] => 0x4ccfb3039b78d3938588157564c9ad559bafab94
[gasUsed] => 3347881
[gasLimit] => 8000000
[avg.GasPrice] => 993239
[reward] => 39209320
)
[1] => Array
(
[blockNumber] => 6764217
[age] => 1573608410
[txn] => 54
[uncles] => 0
[miner] => 0x4ccfb3039b78d3938588157564c9ad559bafab94
[gasUsed] => 2300623
[gasLimit] => 8000000
[avg.GasPrice] => 329329
[reward] => 382938
)
overallBlockListofblockListArrayobjects? Or are you look for an object structured like:{key: blockListArrayData}