How it works?
It works awfully.
First, getting id into the global namespace, as far as I can imagine, is non-standard (although it may already have been standardized). Some time ago it did not work in FF, now it is normal.
Secondly, innerText is creepy. His cross-browser compatibility is very doubtful, it is non-standard and only appeared in the FF 46 version. And in chrome, where it is originally, even at assignment it is ten times slower than the standard textContent .
res.innerText = "Hello, World!"
document.getElementById("res").textContent = "Hello, World!";