Skip to content

Instantly share code, notes, and snippets.

@newbornfrontender
Created January 18, 2019 06:46
Show Gist options
  • Save newbornfrontender/b55c095b2c2ee9fc75a0762fedd14865 to your computer and use it in GitHub Desktop.
Save newbornfrontender/b55c095b2c2ee9fc75a0762fedd14865 to your computer and use it in GitHub Desktop.
Destructuring. Multiple return values
const addres = ['37.6068', '55.7386'];
function getCoordinates(addres) {
const coordinates = {
lon: addres[0],
lat: addres[1],
};
return [coordinates.lon, coordinates.lat];
};
const [longitude, latitude] = getCoordinates(addres);
console.log(`longitude: ${longitude}, latitude: ${latitude}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment