Replies: 1 comment 1 reply
-
Here's how you can do that: const obj = {a: 1, b: 2, c: 3};
const { a, b } = obj;
const newObj = { a, b }; or const obj = {a: 1, b: 2, c: 3};
const newObj = { a: obj.a, b: obj.b }; Note that Node.js doesn't have control over JavaScript the language, discussion over the language spec is happening in https://github.com/tc39/proposals. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to destructure an object and assign it to another object to spread it, is it possible or already exists another way to do that?
If not, it would be good if it can be done like: const obj = {a: 1, b: 2, c: 3}; const a = {a, b} = obj;
Beta Was this translation helpful? Give feedback.
All reactions