Last active
December 12, 2018 12:19
-
-
Save gunn/d85440a6aabe9d62c9581e54a0195804 to your computer and use it in GitHub Desktop.
Destructure to array or object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getVersionDetails = ()=> { | |
const MAJOR = 1 | |
const MINOR = 2 | |
const PATCH = 6 | |
const array = [MAJOR, MINOR, PATCH] | |
const object = {MAJOR, MINOR, PATCH} | |
return Object.assign(array, object) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {MAJOR, MINOR, PATCH} = getVersionDetails() | |
const [major, minor, patch] = getVersionDetails() | |
getVersionDetails().join(".") //-> "1.2.6" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment