Diff Two Arrays - Understanding one of the solutions

Tell us what’s happening:

So after an hour I decided to check out the solutions. :sweat: I completely forgot what the meaning of ... is and I was hoping someone could point out a link I can read because this solution makes sense, but not knowing what ... means throws me off. I tried Googling it but couldn’t find anything. Is there a name for using ...? Thanks.

Your code so far

function diffArray(arr1, arr2) {

  var newArr = [...diff(arr1,arr2), ...diff(arr2,arr1)];
//check if element is in both arrays and remove it
function diff(x,y){
  return x.filter(e => y.indexOf(e) === -1);
  return newArr;

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);

diffArray(["andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"]);

Your browser information:

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

Link to the challenge:

It can either be the spread or the rest operator, depending on how it is used. In this case, it is being used as a spread operator. They are both part of ES6.

1 Like