I use next code for 500k+ array elements and gets max call stack error
:
function getSortedUniqInts(arr) {
const unique = new Set(arr);
return new Array(...unique).sort((a, b) => a - b);
}
But this code works without the error:
function getSortedUniqInts(arr) {
const unique = new Set(arr);
return [...unique].sort((a, b) => a - b);
}
What is the difference between these?