JavaScript group anagram performance
Welcome to Code Review, the complexity of your code can be reduced using a Map object having as keys sorted lexicographically strings and as values arrays of their anagrams. For example you will have the following couples key - value starting from your input:
key = &quot;aet&quot;  value = [&quot;eat&quot;,&quot;tea&quot;,&quot;ate&quot;]
key = &quot;ant&quot;  value = [&quot;tan&quot;,&quot;nat&quot;]
key = &quot;abt&quot;  value = [&quot;bat&quot;]

So you can define a function anagrams like this:
function anagrams(input) {
    const map = new Map();

    for (let i = 0; i &lt; input.length; ++i) {
        const key = [...input[i]].sort().join('');
        const value = map.has(key) ? map.get(key) : [];
        value.push(input[i]);
        map.set(key, value);
    }

    return [...map.values()];
}

/*below it will print the expected result*/
console.log(anagrams([&quot;eat&quot;, &quot;tea&quot;, &quot;tan&quot;, &quot;ate&quot;, &quot;nat&quot;, &quot;bat&quot;])); 

I just used the Spread operator to expand the string input[i] to array of characters and after I sort it to obtain the corrisponding key in the map. After I add it to the array of strings associated to the key and finally I return the map values as an array.
Note: I'm a javascript beginner so every hint or criticism about my answer is highly appreciated.