Skip to content

Commit 36ccac2

Browse files
committed
Use Destructuring Assignment with the Rest Operator
1 parent 0e1b1b1 commit 36ccac2

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

index.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1213,4 +1213,17 @@ let a = 8, b = 6;
12131213
[a,b] = [b,a];
12141214
})();
12151215
console.log(a);
1216-
console.log(b);
1216+
console.log(b);
1217+
1218+
// Use Destructuring Assignment with the Rest Operator
1219+
1220+
const source = [1,2,3,4,5,6,7,8,9,10];
1221+
1222+
function removeFirstTwo(list) {
1223+
const [ , , ...arr] = list;
1224+
1225+
return arr;
1226+
}
1227+
const arr = removeFirstTwo(source);
1228+
console.log(arr);
1229+
console.log(source);

0 commit comments

Comments
 (0)