javascript: how to remove duplicate arrays inside array of arrays

You won’t really get around stringifying the arrays, as that’s the simplest (and reasonably fast) way to compare them by value. So I’d go for

Array.from(new Set(input.map(JSON.stringify)), JSON.parse)

See also Remove Duplicates from JavaScript Array for other approaches, though most of them will require two values to be comparable by ===.

Leave a Comment