How to return an array in JavaScript?

To return an array in JavaScript, do this: return [ value1, value2 ].

Here's how you do it:

function myFunction(a, b) {
  return [ a + 1, b + 2 ];
}

const [ firstValue, secondValue ] = myFunction(10, 10);

// 11 12
console.log(firstValue, secondValue);