javascript function return multiple values code example
Example 1: python return array
def my_function():
result = []
#body of the function
return result
Example 2: javascript return multiple values from a function
function getTopTwoColors() {
return ["blue", "pink"];
}
var topTwoColors=getTopTwoColors();
var firstValue=topTwoColors[0];
var secondValue=topTwoColors[1];
Example 3: return multiple values in javascript
function getNames() {
let firstName = 'John',
lastName = 'Doe';
return {
firstName,
lastName
};
}