'How to instantiate constant as the result without the error?

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


Solution 1:[1]

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

Solution 2:[2]

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

const [result] = function();

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Charlo Poitras
Solution 2 geofh