Say I am defining a series of variables like so:
let test = {one:1, two:2, three:3}
let {one, two, three} = test
This would define the variables one
, two
, and three
with the corresponding values in the test
variable. Now say I want to define all of the values in test
as variables but I don't know the elements inside it. How could I do that?
So far I've tried using an array in it like
let {["one", "two", "three"]} = test
but I get errors
let {["one", "two", "three"]} = test
^
Uncaught SyntaxError: Unexpected token ','
Then I tried using the spread operator first like
let {...["one", "two", "three"]} = test
But that didn't work either and had the same error.
I have absolutely no idea where to continue from here.