JavaScript Coding Question – 1

  • Here, in the above code the line const result = […new Set(arr)] removes duplicate values from the array arr using a Set, which only allows unique values.
  • new Set(arr): Creates a new Set from the array. The Set will only keep unique values.
  • [...new Set(arr)]: The spread operator ... is used to convert the Set back into an array.

Leave a comment