After examining the Typescript code below, I'm curious to understand the rationale behind assigning myArray
with (await asyncRPCCall())[0]
instead of simply using await asyncRPCCall()
. Why is the result placed inside ()
and why return only the first element? I'm interested in what sets this approach apart.
export class myClass {
static async myFunction(): Promise<void> {
const myArray: Array<Array<string>> = (await asyncRPCCall())[0]
console.log(myArray) // returns [['a','b','c','d'],['e','f','g','h']]
}
}