how to return multiple values from a function javascript
//function that returns multiple values
function getTopTwoColors() {
return ["blue", "pink"];
}
var topTwoColors=getTopTwoColors();
var firstValue=topTwoColors[0]; //get first return value
var secondValue=topTwoColors[1]; //get second return value
function getNames() {
// get names from the database or API
let firstName = 'John',
lastName = 'Doe';
// return values
return {
firstName,
lastName
};
}var values = getValues();
var first = values[0];
var second = values[1];
Also in JavaScript:
- javascript map ket to value
- vimeo playback speed
- jquery ajax get
- toastify js
- convert timestamp to date js
- data for bar plot json
- js selection box excel node
- bigint type js
- BottomNavigationBar rebuilds Page on change of tab
- get only numbers regex javascript
- Error: Cannot find module 'ejs'
- jquery when you typing in input
- resellerclub api with react js
- js deep serialize url array
- visual studio appsettings development json not nested appsettings.json
- javascript write to text file
- how to get the year in javascript
- set data-id javascript
- jest manual mock node module
- railsparse json to object
- flutter
- get current date javascript full month
- node read file sync
- jquery get data attribute value