是否通过没有getElementById的ID(作为var)处理元素是否合适?

I've been coding with vanilla JS for quite a few years, but whenever I needed to handle an HTML element with an id attribute I'd reasonably resort to:

var myId = document.getElementById('myId');

当我偶然发现实际上可行时:

function add() {
  let span = document.createElement('span');
  span.innerHTML = '<br />o hi';

  // === THIS: ===
  correctId.appendChild(span);

}
<div id="someId"></div>
<input type="button" value="MOAR" onclick="add()" />
<div id="correctId"><strong>Append here: </strong></div>
<div class="someClass"></div>

得知这一点,我感到震惊。

百万美元的问题是……这甚至是好的实践还是标准?我可以在我的代码中安全地使用它吗?或者它是最近添加,已弃用,针对浏览器的甚至是危险的?

I didn't even know how to look for references on this behavior. I tried looking for "element id as variable", "using ids as var names" and so on. Nothing. Everywhere I go people mention document.getElementById(), document.querySelector('#'), jQuery, but never that one behavior - that elements with an id attribute are already available as variables in JavaScript, or at least that's how I understood it.

我正在使用Chrome 81.0.4044.138。任何人都可以对此进行点灯吗?