Home | Mailing List | Blog | Tutorial Videos

Set Uniqueness and Ordering

In the following problem, we use the Set object and spread syntax to create a new array. What gets logged (to consider: Are items forced to be unique? Are they sorted?)

const arr = [...new Set([3, 1, 2, 3, 4])];
console.log(arr.length, arr[2]);

Select one: