Please, using for loops is okay, especially if you're not actually writing functional code.
[...document.xpath("//text()[contains(., 'Hello')]")]
.forEach(node => node.textContent = node.textContent.replace("Hello", "Greetings"));
versus for (const node of document.xpath("//text()[contains(., 'Hello')]"){
node.textContent = node.textContent.replace("Hello", "Greetings");
}
No allocation of a pointless array, no redundant iteration, fewer "[]", "()" and no "=>" or "...". No downside whatsoever!