Es6 destructuring question

hey guys, is there anyway using es6 destructuring so I can remove the first element of args array? or using to mark the rest of them? having some difficulties with the docs.

edit: I have found a solution with slice, just wondering if possible with using destructuring too thanks.

  **Your code so far**

function destroyer(arr) {
const args = [...arguments]
/*console.log(args[0].filter((num) => {
  if (num.includes) {


destroyer([1, 2, 3, 1, 2, 3], 2, 3);
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36

Challenge: Seek and Destroy

Link to the challenge:

You mean like this?

function destroyer(firstEl, {
1 Like

You mean something like this:

const arr1 = [1, 2, 3]
const [x, ...arr2] = arr1

// [2, 3]

const args = [...arguments] const [x, arr2] = args
would it possible to give an example in my example?

function destroyer(arr,
i solved the challenge, but I saw at the solutions this is also possible to use.
but just for my knowledge is it possible to do with my first example?

const args = [...arguments] const [x, arr2] = args
this gives me 2, and not the rest like I want.

Yes this is good, but still wondering if it’s possible in the example that I gave below.

You mean like this?

const args = [...arguments]
const [x, ...arr2] = args
1 Like

thanks a lot! , I was missing the destructuring syntax from my example lol

1 Like

just to be completely clear, this is both variants of the ... operator.

In the first line, const args = [...arguments], we have the spread version of the operator. We are “spreading” each item in arguments as a comma-separated list within the [ ].

In the second line, const [x, ...arr2] - args we have the rest operator. Here, we are capturing “the rest” of the elements in the args array.

Whether it is rest or spread is determined by which side of the assignment we find it. If on the left (variable) side, it’s rest - if on the right (expression) side, it’s spread.

The exception is an implied assignment: the parameters of a function. When we are defining parameters, we are defining the variable side of an assignment, so when we see:

const removeFromArray( original, ...removeThese){


In that, ...removeThese is an implied rest operator.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.