MoonL
MoonL

Reputation: 21

How To const/let/var Multiple const/let/var in one const/let/var

Hey i wanna ask how to const all const in one like

const a = "a"
const b = "b"
const c = "c"

can I just const all = `a,b,c` ??

Upvotes: 1

Views: 64

Answers (2)

hgb123
hgb123

Reputation: 14891

You could use destructing assignment

const [a, b, c] = ["a", "b", "c"]

console.log(a, b, c)

Upvotes: 1

ProfDFrancis
ProfDFrancis

Reputation: 9411

Multi-variable assignments

Yes, you can do it like this:

const a="a", b="b", c="c"

Upvotes: 1

Related Questions