Many years ago when I studied JavaScript, that I later almost did not use, I learned that I could use element id in place of its name. E.g.:
if we have code like this:
<button type="button" id="addButton">Add</button>
we can use the element two ways:
addButton.addEventListener('click', function(){
console.log('click');
});
or
document.getElementById('addButton').addEventListener('click', function(){
console.log('click');
});
The former version looks more convenient to me, but I found that nobody uses it. Why? What's the difference?