Skip to content

Instantly share code, notes, and snippets.

@MarsiBarsi
Created August 6, 2021 08:55
Show Gist options
  • Save MarsiBarsi/c405752bba813fb4f4a6b1aee5fb09c7 to your computer and use it in GitHub Desktop.
Save MarsiBarsi/c405752bba813fb4f4a6b1aee5fb09c7 to your computer and use it in GitHub Desktop.
const environment = {
type: 'prod',
variables: {
api: 'some-url',
port: '8080'
}
}
const {
type: envType, // we extract "type" and call it "envType" here
variables: { api: envApi, ...envRest } // we extract "api" as "envApi" and add the rest into "envRest"
} = environment;
console.log(envType); // 'prod'
console.log(envApi); // 'some-url'
console.log(envRest); // {port: '8080'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment