Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bkinsey808/5d1089c948ed9eb2bd2e6a32bfbb50cd to your computer and use it in GitHub Desktop.
Save bkinsey808/5d1089c948ed9eb2bd2e6a32bfbb50cd to your computer and use it in GitHub Desktop.
// consider the following case
let a, b, c
if (condition) {
a = 1
b = 2
c = 3
}
// how would this be refactored into constantly const?
const [a, b, c] = condition
? [1, 2, 3]
: [undefined, undefined, undefined]
// or maybe
const {a, b, c} = condition
? { a: 1, b: 2, c: 3}
: { a: undefined, b: undefined, c: undefined }
// again, i run into a case like this so infrequently (or maybe never)
// so it really doesn't have much bearing for me.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment