function twoValues() {
return [0, 1];
}
let [first, second] = twoValues();
function getNames() {
// get names from the database or API
let firstName = 'John',
lastName = 'Doe';
// return as an array
return [firstName, lastName];
}
Code language: JavaScript (javascript)