Destructuring - JavaScript | MDN

developer.mozilla.org

Tin mới

HTML: Markup language

See all HTML references

Date & time formats

See all HTML guides

CSS: Styling language

See all CSS references

See all CSS guides

Centering an element

JavaScript: Scripting language

Standard built-in objects

Expressions & operators

Statements & declarations

See all JavaScript references

Control flow & error handing

Loops and iteration

Working with objects

See all JavaScript guides

Web APIs: Programming interfaces

Service worker API

Using the Web animation API

Using the Fetch API

Working with the History API

Using the Web speech API

All web technology

Progressive web apps

Learn web development

Getting started modules

Structuring content with HTML module

CSS styling basics module

Dynamic scripting with JavaScript module

Border-image generator

Border-radius generator

Box-shadow generator

Color format converter

expression statements

Note: The parentheses ( ... ) around the assignment statement are required when using object literal destructuring without a declaration.

Binding and assignment

For both object and array destructuring, there are two kinds of destructuring patterns: binding pattern and assignment pattern, with slightly different syntaxes.

Array destructuring

In an array destructuring from an array of length N specified on the right-hand side of the assignment, if the number of variables specified on the left-hand side of the assignment is greater than N, only the first N var

Array destructuring

In an array destructuring from an array of length N specified on the right-hand side of the assignment, if the number of variables specified on the left-hand side of the assignment is greater than N, only the first N var

Default parameters > Destructured parameter with default value assignment

A property can be unpacked from an object and assigned to a variable with a different name than the object property.

Object destructuring

A property can be unpacked from an object and assigned to a variable with a different name than the object property.

Object destructuring

A property can be unpacked from an object and assigned to a variable with a different name than the object property.

property accessing

Object destructuring is almost equivalent to property accessing. This means if you try to destruct a primitive value, the value will get wrapped into the corresponding wrapper object and the property is accessed on the w

Destructuring primitive values

Object destructuring is almost equivalent to property accessing. This means if you try to destruct a primitive value, the value will get wrapped into the corresponding wrapper object and the property is accessed on the w

Learn how to contribute

This page was last modified on Aug 10, 2026 by MDN contributors.

Expressions and operators

Numbers and strings

Representing dates & times

Regular expressions

Indexed collections

JavaScript typed arrays