Diff Two Array Alghritm - Warning: contains a solution

Can someone explain me what’s the meaning of:

item => !arr1.includes(item) || !arr2.includes(item)

and what is this operator: =>

in this code snippet;

function diffArray(arr1, arr2) {
  return arr1 
    .concat(arr2)
    .filter(
      item => !arr1.includes(item) || !arr2.includes(item) 
    )
}

Thanks

It’s the ES2015 ‘fat arrow’ way to create a function.

Read up on JS Fat Arrow and it should make sense in this context.

.filter(
      item => !arr1.includes(item) || !arr2.includes(item) 
    )

is equivalent to :

.filter(
      function(item) { return !arr1.includes(item) || !arr2.includes(item) } 
    )

Though, there are differences :

Back to the code :

function diffArray(arr1, arr2) {
  return arr1 
    .concat(arr2)
    .filter(
      item => !arr1.includes(item) || !arr2.includes(item) 
    )
}

diffArray merges arr1 and arr2, and returns this merged array without elements (item) that belong to both arr1 and arr2

Thanks. Now it’s all clear.