Not sure this is a Developer Tools related question... Seems a bit like a JavaScript/DOM related question (out of scope).
$x as well as $$ return an array of elements, so you can do whatever you want with this array.
$$("a.username").map(element => element.innerHTML); // will return an array of innerHTML values of a.username.
The XPath equivalent (assuming the class attribute has only username in it, no spaces) is $x("//a[@class = 'username']").map(element => element.innerHTML); but you need to familiarize yourself with XPath a bit (if you have not already) in order to cook up similarly more-complex selectors.