Skip to content

Commit 0e1b1b1

Browse files
committed
Use Destructuring Assignment to Assign VAriables from Arrays
1 parent 56430be commit 0e1b1b1

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

index.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1199,4 +1199,18 @@ function getMaxOfTmrw(forecast) {
11991199

12001200
}
12011201

1202-
console.log(getMaxOfTmrw(LOCAL_FORECAST)); // should be 79
1202+
console.log(getMaxOfTmrw(LOCAL_FORECAST)); // should be 79
1203+
1204+
// Use Destructuring Assignment to Assign VAriables from Arrays
1205+
1206+
const [z, x, , y] = [1, 2, 3, 4, 5, 6];
1207+
console.log(z, x, y);
1208+
1209+
let a = 8, b = 6;
1210+
(() => {
1211+
"use strict";
1212+
//new line
1213+
[a,b] = [b,a];
1214+
})();
1215+
console.log(a);
1216+
console.log(b);

0 commit comments

Comments
 (0)