diff --git a/files/en-us/web/javascript/reference/operators/destructuring_assignment/index.html b/files/en-us/web/javascript/reference/operators/destructuring_assignment/index.html index 757bffe14fcd918..7c7601b6457dd85 100644 --- a/files/en-us/web/javascript/reference/operators/destructuring_assignment/index.html +++ b/files/en-us/web/javascript/reference/operators/destructuring_assignment/index.html @@ -56,6 +56,14 @@

Description

console.log(z); // 2 +

Similarly, you can destructure arrays on the left-hand side of the assignment

+ +
const [firstElement, secondElement] = list;
+// is equivalent to:
+// const firstElement = list[0];
+// const secondElement = list[1];
+
+

This capability is similar to features present in languages such as Perl and Python.

Examples

@@ -74,7 +82,7 @@

Basic variable assignment

Assignment separate from declaration

-

A variable can be assigned its value via destructuring separate from the variable's declaration.

+

A variable can be assigned its value via destructuring, separate from the variable's declaration.

let a, b;