Home > Mobile >  How to instantiate constant as the result without the error?
How to instantiate constant as the result without the error?

Time:04-26

a function returns an array of [result, error]

Right now I am instantiating the constant as the array:

const [result, error] = function

How do I instantiate only the result element like this:

const result = function

CodePudding user response:

You can probably extract it directly from your function
const result = function().result

CodePudding user response:

If you're only interested in the first element returned by the function, it can simply be

const [result] = function();
  • Related