2018-10-12 16:35:31 -04:00
|
|
|
---
|
|
|
|
title: Use Destructuring Assignment with the Rest Operator to Reassign Array Elements
|
|
|
|
localeTitle: استخدم Destructuring Assignment مع عامل التشغيل الباقي لإعادة تعيين عناصر المصفوفة
|
|
|
|
---
|
|
|
|
## استخدم Destructuring Assignment مع عامل التشغيل الباقي لإعادة تعيين عناصر المصفوفة
|
|
|
|
|
|
|
|
تذكر أن المشغل الباقي يسمح للأعداد المتغيرة من الوسيطات. في هذا التحدي ، عليك التخلص من العنصرين الأولين في مصفوفة.
|
|
|
|
|
|
|
|
## تلميح 1:
|
|
|
|
|
|
|
|
قم بتعيين أول عنصرين إلى متغيرين عشوائيين.
|
|
|
|
|
|
|
|
## تلميح 2:
|
|
|
|
|
|
|
|
اضبط الجزء المتبقي من المصفوفة على `...arr` .
|
|
|
|
|
|
|
|
\=======
|
|
|
|
|
|
|
|
## تلميح 1
|
|
|
|
|
|
|
|
استخدم destructuring لإنشاء متغير `arr` .
|
|
|
|
|
2019-06-20 14:07:46 -07:00
|
|
|
```javascript
|
|
|
|
function removeFirstTwo(list) {
|
|
|
|
"use strict";
|
|
|
|
// change code below this line
|
|
|
|
const [arr] = list; // change this
|
|
|
|
// change code above this line
|
|
|
|
return arr;
|
|
|
|
}
|
|
|
|
```
|
2018-10-12 16:35:31 -04:00
|
|
|
|
|
|
|
## تلميح 2
|
|
|
|
|
|
|
|
انشر معلمة `list` في `arr` .
|
|
|
|
|
2019-06-20 14:07:46 -07:00
|
|
|
```javascript
|
|
|
|
function removeFirstTwo(list) {
|
|
|
|
"use strict";
|
|
|
|
// change code below this line
|
|
|
|
const [...arr] = list; // change this
|
|
|
|
// change code above this line
|
|
|
|
return arr;
|
|
|
|
}
|
|
|
|
```
|
2018-10-12 16:35:31 -04:00
|
|
|
|
|
|
|
## تلميح 3
|
|
|
|
|
|
|
|
استبعاد أول عنصرين من صفيف `arr` مع `,,` .
|
|
|
|
|
2019-06-20 14:07:46 -07:00
|
|
|
```javascript
|
|
|
|
function removeFirstTwo(list) {
|
|
|
|
"use strict";
|
|
|
|
// change code below this line
|
|
|
|
const [,,...arr] = list; // change this
|
|
|
|
// change code above this line
|
|
|
|
return arr;
|
|
|
|
}
|
|
|
|
```
|
2018-10-12 16:35:31 -04:00
|
|
|
|
|
|
|
## تنبيه المفسد - الحل إلى الأمام!
|
|
|
|
|
2019-06-20 14:07:46 -07:00
|
|
|
```javascript
|
|
|
|
function removeFirstTwo(list) {
|
|
|
|
"use strict";
|
|
|
|
// change code below this line
|
|
|
|
const [a, b, ...arr] = list;
|
|
|
|
// change code above this line
|
|
|
|
return arr;
|
|
|
|
}
|
|
|
|
```
|