let data = {"a":1,"b":2};
I want to destructure this object to automatically create 2 variable with names equal to key without providing the name. How can I do that? Can I even do that without specifying the keynames?
let {} = data;
console.log(a)
should then give 1
Is this possible?
The reason I want this is because I have string , str = `runcode -s ${a} `
I want to get the value of "a" automatically when I run str
Even if I change the str to `runcode -s ${data.a} ` and run str
, the data.a
doesn't get replace by 1
. How can I solve this ?