Syntax
JavaScript Destructure an Object Syntax
In JavaScript, destructure an object: pulls properties into variables — const { name, age } = user;
Quick Answer
- Syntax
const { name, age } = user;
JavaScriptSyntax
Destructure an Object
Code example
const { name, age } = user;
Pulls properties into variables.
How to destructure an object in JavaScript
- Open your JavaScript file or editor.
- Copy the example, then replace its sample names and values for your code.
JavaScript Destructure an Object Syntax
Use const { name, age } = user;.
Related Syntax References
Frequently asked questions
What is the JavaScript syntax for destructure an object?
Use this pattern: const { name, age } = user;
Can I copy this JavaScript code example?
Yes. Use Copy code and adapt the example to your program.
Is this JavaScript syntax different on Mac or Windows?
No. The language syntax is the same across operating systems.
Official source · How we verify